Skip to content

Commit

Permalink
feat: Add conferences to native java bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Mar 16, 2024
1 parent 2494bba commit 4183a0e
Showing 1 changed file with 219 additions and 60 deletions.
279 changes: 219 additions & 60 deletions lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreJni.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,66 +19,225 @@

@SuppressWarnings({"checkstyle:emptylineseparator", "checkstyle:linelength"})
public final class ToxCoreJni {
static {
System.loadLibrary("tox4j-c");
}
static {
System.loadLibrary("tox4j-c");
}

static native int toxNew(boolean ipv6Enabled, boolean udpEnabled, boolean localDiscoveryEnabled,
int proxyType, String proxyAddress, int proxyPort, int startPort, int endPort, int tcpPort,
int saveDataType, byte[] saveData) throws ToxNewException;
static native int toxNew(boolean ipv6Enabled, boolean udpEnabled, boolean localDiscoveryEnabled,
int proxyType, String proxyAddress, int proxyPort, int startPort, int endPort, int tcpPort,
int saveDataType, byte[] saveData) throws ToxNewException;

static native void toxKill(int instanceNumber);
static native void toxFinalize(int instanceNumber);
static native byte[] toxGetSavedata(int instanceNumber);
static native void toxBootstrap(int instanceNumber, String address, int port, byte[] publicKey)
throws ToxBootstrapException;
static native void toxAddTcpRelay(int instanceNumber, String address, int port, byte[] publicKey)
throws ToxBootstrapException;
static native int toxSelfGetUdpPort(int instanceNumber) throws ToxGetPortException;
static native int toxSelfGetTcpPort(int instanceNumber) throws ToxGetPortException;
static native byte[] toxSelfGetDhtId(int instanceNumber);
static native int toxIterationInterval(int instanceNumber);
static native byte[] toxIterate(int instanceNumber);
static native byte[] toxSelfGetPublicKey(int instanceNumber);
static native byte[] toxSelfGetSecretKey(int instanceNumber);
static native void toxSelfSetNospam(int instanceNumber, int nospam);
static native int toxSelfGetNospam(int instanceNumber);
static native byte[] toxSelfGetAddress(int instanceNumber);
static native void toxSelfSetName(int instanceNumber, byte[] name) throws ToxSetInfoException;
static native byte[] toxSelfGetName(int instanceNumber);
static native void toxSelfSetStatusMessage(int instanceNumber, byte[] message)
throws ToxSetInfoException;
static native byte[] toxSelfGetStatusMessage(int instanceNumber);
static native void toxSelfSetStatus(int instanceNumber, int status);
static native int toxSelfGetStatus(int instanceNumber);
static native int toxFriendAdd(int instanceNumber, byte[] address, byte[] message)
throws ToxFriendAddException;
static native int toxFriendAddNorequest(int instanceNumber, byte[] publicKey)
throws ToxFriendAddException;
static native void toxFriendDelete(int instanceNumber, int friendNumber)
throws ToxFriendDeleteException;
static native int toxFriendByPublicKey(int instanceNumber, byte[] publicKey)
throws ToxFriendByPublicKeyException;
static native byte[] toxFriendGetPublicKey(int instanceNumber, int friendNumber)
throws ToxFriendGetPublicKeyException;
static native boolean toxFriendExists(int instanceNumber, int friendNumber);
static native int[] toxSelfGetFriendList(int instanceNumber);
static native void toxSelfSetTyping(int instanceNumber, int friendNumber, boolean typing)
throws ToxSetTypingException;
static native int toxFriendSendMessage(int instanceNumber, int friendNumber, int type,
int timeDelta, byte[] message) throws ToxFriendSendMessageException;
static native void toxFileControl(int instanceNumber, int friendNumber, int fileNumber,
int control) throws ToxFileControlException;
static native void toxFileSeek(int instanceNumber, int friendNumber, int fileNumber,
long position) throws ToxFileSeekException;
static native int toxFileSend(int instanceNumber, int friendNumber, int kind, long fileSize,
byte[] fileId, byte[] filename) throws ToxFileSendException;
static native void toxFileSendChunk(int instanceNumber, int friendNumber, int fileNumber,
long position, byte[] data) throws ToxFileSendChunkException;
static native byte[] toxFileGetFileId(int instanceNumber, int friendNumber, int fileNumber)
throws ToxFileGetException;
static native void toxFriendSendLossyPacket(int instanceNumber, int friendNumber, byte[] data)
throws ToxFriendCustomPacketException;
static native void toxFriendSendLosslessPacket(int instanceNumber, int friendNumber, byte[] data)
throws ToxFriendCustomPacketException;
// void tox_kill(Tox *tox);
static native void toxKill(int instanceNumber);
static native void toxFinalize(int instanceNumber);
// void tox_get_savedata(const Tox *tox, uint8_t savedata[]);
static native byte[] toxGetSavedata(int instanceNumber);
// bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Bootstrap *error);
static native void toxBootstrap(int instanceNumber, String address, int port, byte[] publicKey)
throws ToxBootstrapException;
// bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Bootstrap *error);
static native void toxAddTcpRelay(int instanceNumber, String address, int port, byte[] publicKey)
throws ToxBootstrapException;
// uint16_t tox_self_get_udp_port(const Tox *tox, Tox_Err_Get_Port *error);
static native int toxSelfGetUdpPort(int instanceNumber) throws ToxGetPortException;
// uint16_t tox_self_get_tcp_port(const Tox *tox, Tox_Err_Get_Port *error);
static native int toxSelfGetTcpPort(int instanceNumber) throws ToxGetPortException;
// void tox_self_get_dht_id(const Tox *tox, uint8_t dht_id[TOX_PUBLIC_KEY_SIZE]);
static native byte[] toxSelfGetDhtId(int instanceNumber);
// uint32_t tox_iteration_interval(const Tox *tox);
static native int toxIterationInterval(int instanceNumber);
// void tox_iterate(Tox *tox, void *user_data);
static native byte[] toxIterate(int instanceNumber);
// void tox_self_get_public_key(const Tox *tox, uint8_t public_key[TOX_PUBLIC_KEY_SIZE]);
static native byte[] toxSelfGetPublicKey(int instanceNumber);
// void tox_self_get_secret_key(const Tox *tox, uint8_t secret_key[TOX_SECRET_KEY_SIZE]);
static native byte[] toxSelfGetSecretKey(int instanceNumber);
// void tox_self_set_nospam(Tox *tox, uint32_t nospam);
static native void toxSelfSetNospam(int instanceNumber, int nospam);
// uint32_t tox_self_get_nospam(const Tox *tox);
static native int toxSelfGetNospam(int instanceNumber);
// void tox_self_get_address(const Tox *tox, uint8_t address[TOX_ADDRESS_SIZE]);
static native byte[] toxSelfGetAddress(int instanceNumber);
// bool tox_self_set_name(Tox *tox, const uint8_t name[], size_t length, Tox_Err_Set_Info *error);
static native void toxSelfSetName(int instanceNumber, byte[] name) throws ToxSetInfoException;
// void tox_self_get_name(const Tox *tox, uint8_t name[]);
static native byte[] toxSelfGetName(int instanceNumber);
// bool tox_self_set_status_message(
// Tox *tox, const uint8_t status_message[], size_t length, Tox_Err_Set_Info *error);
static native void toxSelfSetStatusMessage(int instanceNumber, byte[] message)
throws ToxSetInfoException;
// void tox_self_get_status_message(const Tox *tox, uint8_t status_message[]);
static native byte[] toxSelfGetStatusMessage(int instanceNumber);
// void tox_self_set_status(Tox *tox, Tox_User_Status status);
static native void toxSelfSetStatus(int instanceNumber, int status);
// Tox_User_Status tox_self_get_status(const Tox *tox);
static native int toxSelfGetStatus(int instanceNumber);
// Tox_Friend_Number tox_friend_add(
// Tox *tox, const uint8_t address[TOX_ADDRESS_SIZE],
// const uint8_t message[], size_t length,
// Tox_Err_Friend_Add *error);
static native int toxFriendAdd(int instanceNumber, byte[] address, byte[] message)
throws ToxFriendAddException;
// Tox_Friend_Number tox_friend_add_norequest(
// Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Friend_Add *error);
static native int toxFriendAddNorequest(int instanceNumber, byte[] publicKey)
throws ToxFriendAddException;
// bool tox_friend_delete(Tox *tox, Tox_Friend_Number friend_number, Tox_Err_Friend_Delete *error);
static native void toxFriendDelete(int instanceNumber, int friendNumber)
throws ToxFriendDeleteException;
// Tox_Friend_Number tox_friend_by_public_key(const Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Friend_By_Public_Key *error);
static native int toxFriendByPublicKey(int instanceNumber, byte[] publicKey)
throws ToxFriendByPublicKeyException;
// bool tox_friend_get_public_key(
// const Tox *tox, Tox_Friend_Number friend_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
// Tox_Err_Friend_Get_Public_Key *error);
static native byte[] toxFriendGetPublicKey(int instanceNumber, int friendNumber)
throws ToxFriendGetPublicKeyException;
// bool tox_friend_exists(const Tox *tox, Tox_Friend_Number friend_number);
static native boolean toxFriendExists(int instanceNumber, int friendNumber);
// void tox_self_get_friend_list(const Tox *tox, Tox_Friend_Number friend_list[]);
static native int[] toxSelfGetFriendList(int instanceNumber);
// bool tox_self_set_typing(
// Tox *tox, Tox_Friend_Number friend_number, bool typing, Tox_Err_Set_Typing *error);
static native void toxSelfSetTyping(int instanceNumber, int friendNumber, boolean typing)
throws ToxSetTypingException;
// Tox_Friend_Message_Id tox_friend_send_message(
// Tox *tox, Tox_Friend_Number friend_number, Tox_Message_Type type,
// const uint8_t message[], size_t length, Tox_Err_Friend_Send_Message *error);
static native int toxFriendSendMessage(int instanceNumber, int friendNumber, int type,
int timeDelta, byte[] message) throws ToxFriendSendMessageException;
// bool tox_file_control(
// Tox *tox, Tox_Friend_Number friend_number, Tox_File_Number file_number, Tox_File_Control control,
// Tox_Err_File_Control *error);
static native void toxFileControl(int instanceNumber, int friendNumber, int fileNumber,
int control) throws ToxFileControlException;
// bool tox_file_seek(
// Tox *tox, Tox_Friend_Number friend_number, Tox_File_Number file_number, uint64_t position, Tox_Err_File_Seek *error);
static native void toxFileSeek(int instanceNumber, int friendNumber, int fileNumber,
long position) throws ToxFileSeekException;
// Tox_File_Number tox_file_send(
// Tox *tox, Tox_Friend_Number friend_number, uint32_t kind, uint64_t file_size,
// const uint8_t file_id[TOX_FILE_ID_LENGTH], const uint8_t filename[], size_t filename_length,
// Tox_Err_File_Send *error);
static native int toxFileSend(int instanceNumber, int friendNumber, int kind, long fileSize,
byte[] fileId, byte[] filename) throws ToxFileSendException;
// bool tox_file_send_chunk(
// Tox *tox, Tox_Friend_Number friend_number, Tox_File_Number file_number, uint64_t position,
// const uint8_t data[], size_t length, Tox_Err_File_Send_Chunk *error);
static native void toxFileSendChunk(int instanceNumber, int friendNumber, int fileNumber,
long position, byte[] data) throws ToxFileSendChunkException;
// bool tox_file_get_file_id(
// const Tox *tox, Tox_Friend_Number friend_number, Tox_File_Number file_number,
// uint8_t file_id[TOX_FILE_ID_LENGTH],
// Tox_Err_File_Get *error);
static native byte[] toxFileGetFileId(int instanceNumber, int friendNumber, int fileNumber)
throws ToxFileGetException;
// bool tox_friend_send_lossy_packet(
// Tox *tox, Tox_Friend_Number friend_number,
// const uint8_t data[], size_t length,
// Tox_Err_Friend_Custom_Packet *error);
static native void toxFriendSendLossyPacket(int instanceNumber, int friendNumber, byte[] data)
throws ToxFriendCustomPacketException;
// bool tox_friend_send_lossless_packet(
// Tox *tox, Tox_Friend_Number friend_number,
// const uint8_t data[], size_t length,
// Tox_Err_Friend_Custom_Packet *error);
static native void toxFriendSendLosslessPacket(int instanceNumber, int friendNumber, byte[] data)
throws ToxFriendCustomPacketException;
// Tox_Conference_Number tox_conference_new(Tox *tox, Tox_Err_Conference_New *error);
static native int toxConferenceNew(int instanceNumber);
// bool tox_conference_delete(Tox *tox, Tox_Conference_Number conference_number, Tox_Err_Conference_Delete *error);
static native void toxConferenceDelete(int instanceNumber, int conferenceNumber);
// uint32_t tox_conference_peer_count(
// const Tox *tox, Tox_Conference_Number conference_number, Tox_Err_Conference_Peer_Query *error);
static native int toxConferencePeerCount(int instanceNumber, int conferenceNumber)
throws ToxConferencePeerQueryException;
// bool tox_conference_peer_get_name(
// const Tox *tox, Tox_Conference_Number conference_number, Tox_Conference_Peer_Number peer_number,
// uint8_t name[], Tox_Err_Conference_Peer_Query *error);
static native byte[] toxConferencePeerGetName(int instanceNumber, int conferenceNumber,
int peerNumber) throws ToxConferencePeerQueryException;
// bool tox_conference_peer_get_public_key(
// const Tox *tox, Tox_Conference_Number conference_number, Tox_Conference_Peer_Number peer_number,
// uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Conference_Peer_Query *error);
static native byte[] toxConferencePeerGetPublicKey(int instanceNumber, int conferenceNumber,
int peerNumber) throws ToxConferencePeerQueryException;
// bool tox_conference_peer_number_is_ours(
// const Tox *tox, Tox_Conference_Number conference_number, Tox_Conference_Peer_Number peer_number,
// Tox_Err_Conference_Peer_Query *error);
static native boolean toxConferencePeerNumberIsOurs(int instanceNumber, int conferenceNumber,
int peerNumber) throws ToxConferencePeerQueryException;
// uint32_t tox_conference_offline_peer_count(
// const Tox *tox, Tox_Conference_Number conference_number,
// Tox_Err_Conference_Peer_Query *error);
static native int toxConferenceOfflinePeerCount(int instanceNumber, int conferenceNumber)
throws ToxConferencePeerQueryException;
// bool tox_conference_offline_peer_get_name(
// const Tox *tox, Tox_Conference_Number conference_number, Tox_Conference_Offline_Peer_Number offline_peer_number,
// uint8_t name[], Tox_Err_Conference_Peer_Query *error);
static native byte[] toxConferenceOfflinePeerGetName(int instanceNumber, int conferenceNumber,
int offlinePeerNumber) throws ToxConferencePeerQueryException;
// bool tox_conference_offline_peer_get_public_key(
// const Tox *tox, Tox_Conference_Number conference_number,
// Tox_Conference_Offline_Peer_Number offline_peer_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Conference_Peer_Query *error);
static native byte[] toxConferenceOfflinePeerGetPublicKey(int instanceNumber, int conferenceNumber,
int offlinePeerNumber) throws ToxConferencePeerQueryException;
// uint64_t tox_conference_offline_peer_get_last_active(
// const Tox *tox, Tox_Conference_Number conference_number,
// Tox_Conference_Offline_Peer_Number offline_peer_number, Tox_Err_Conference_Peer_Query *error);
static native long toxConferenceOfflinePeerGetLastActive(int instanceNumber, int conferenceNumber,
int offlinePeerNumber) throws ToxConferencePeerQueryException;
// bool tox_conference_set_max_offline(
// Tox *tox, Tox_Conference_Number conference_number, uint32_t max_offline,
// Tox_Err_Conference_Set_Max_Offline *error);
static native void toxConferenceSetMaxOffline(int instanceNumber, int conferenceNumber,
int maxOffline) throws ToxConferenceSetMaxOfflineException;
// bool tox_conference_invite(
// Tox *tox, Tox_Friend_Number friend_number, Tox_Conference_Number conference_number,
// Tox_Err_Conference_Invite *error);
static native void toxConferenceInvite(int instanceNumber, int friendNumber, int conferenceNumber)
throws ToxConferenceInviteException;
// Tox_Conference_Number tox_conference_join(
// Tox *tox, Tox_Friend_Number friend_number,
// const uint8_t cookie[], size_t length,
// Tox_Err_Conference_Join *error);
static native int toxConferenceJoin(int instanceNumber, int friendNumber, byte[] cookie)
throws ToxConferenceJoinException;
// bool tox_conference_send_message(
// Tox *tox, Tox_Conference_Number conference_number, Tox_Message_Type type,
// const uint8_t message[], size_t length,
// Tox_Err_Conference_Send_Message *error);
static native void toxConferenceSendMessage(int instanceNumber, int conferenceNumber, int type,
byte[] message) throws ToxConferenceSendMessageException;
// bool tox_conference_get_title(
// const Tox *tox, Tox_Conference_Number conference_number,
// uint8_t title[],
// Tox_Err_Conference_Title *error);
static native byte[] toxConferenceGetTitle(int instanceNumber, int conferenceNumber)
throws ToxConferenceTitleException;
// bool tox_conference_set_title(
// Tox *tox, Tox_Conference_Number conference_number,
// const uint8_t title[], size_t length,
// Tox_Err_Conference_Title *error);
static native void toxConferenceSetTitle(int instanceNumber, int conferenceNumber, byte[] title)
throws ToxConferenceTitleException;
// void tox_conference_get_chatlist(const Tox *tox, Tox_Conference_Number chatlist[]);
static native int[] toxConferenceGetChatlist(int instanceNumber);
// Tox_Conference_Type tox_conference_get_type(
// const Tox *tox, Tox_Conference_Number conference_number,
// Tox_Err_Conference_Get_Type *error);
static native int toxConferenceGetType(int instanceNumber, int conferenceNumber)
throws ToxConferenceGetTypeException;
// bool tox_conference_get_id(
// const Tox *tox, Tox_Conference_Number conference_number, uint8_t id[TOX_CONFERENCE_ID_SIZE]);
static native byte[] toxConferenceGetId(int instanceNumber, int conferenceNumber);
// Tox_Conference_Number tox_conference_by_id(
// const Tox *tox, const uint8_t id[TOX_CONFERENCE_ID_SIZE], Tox_Err_Conference_By_Id *error);
static native int toxConferenceById(int instanceNumber, byte[] id) throws ToxConferenceByIdException;
// bool tox_conference_get_uid(
// const Tox *tox, Tox_Conference_Number conference_number, uint8_t uid[TOX_CONFERENCE_UID_SIZE]);
static native byte[] toxConferenceGetUid(int instanceNumber, int conferenceNumber);
// Tox_Conference_Number tox_conference_by_uid(
// const Tox *tox, const uint8_t uid[TOX_CONFERENCE_UID_SIZE], Tox_Err_Conference_By_Uid *error);
static native int toxConferenceByUid(int instanceNumber, byte[] uid) throws ToxConferenceByUidException;
}

0 comments on commit 4183a0e

Please sign in to comment.