diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/ToxAv.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/ToxAv.kt index bdfa93525..655bed880 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/ToxAv.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/ToxAv.kt @@ -62,9 +62,9 @@ interface ToxAv : AutoCloseable { /** * Call a friend. This will start ringing the friend. * - * It is the client's responsibility to stop ringing after a certain timeout, if such behaviour is - * desired. If the client does not stop ringing, the library will not stop until the friend is - * disconnected. + * It is the client's responsibility to stop ringing after a certain timeout, if such behaviour + * is desired. If the client does not stop ringing, the library will not stop until the friend + * is disconnected. * * @param friendNumber The friend number of the friend that should be called. * @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending. @@ -80,8 +80,8 @@ interface ToxAv : AutoCloseable { /** * Accept an incoming call. * - * If answering fails for any reason, the call will still be pending and it is possible to try and - * answer it later. + * If answering fails for any reason, the call will still be pending and it is possible to try + * and answer it later. * * @param friendNumber The friend number of the friend that is calling. * @param audioBitRate Audio bit rate in Kb/sec. Set this to 0 to disable audio sending. @@ -135,10 +135,10 @@ interface ToxAv : AutoCloseable { /** * Send an audio frame to a friend. * - * The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... Meaning: sample 1 - * for channel 1, sample 1 for channel 2, ... For mono audio, this has no meaning, every sample is - * subsequent. For stereo, this means the expected format is LRLRLR... with samples for left and - * right alternating. + * The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]... Meaning: sample + * 1 for channel 1, sample 1 for channel 2, ... For mono audio, this has no meaning, every + * sample is subsequent. For stereo, this means the expected format is LRLRLR... with samples + * for left and right alternating. * * @param friendNumber The friend number of the friend to which to send an audio frame. * @param pcm An array of audio samples. The size of this array must be sample_count * channels. @@ -161,8 +161,8 @@ interface ToxAv : AutoCloseable { /** * Send a video frame to a friend. * - * Y - plane should be of size: height * width U - plane should be of size: (height/2) * (width/2) - * V - plane should be of size: (height/2) * (width/2) + * Y - plane should be of size: height * width U - plane should be of size: (height/2) * + * (width/2) V - plane should be of size: (height/2) * (width/2) * * @param friendNumber The friend number of the friend to which to send a video frame. * @param width Width of the frame in pixels. diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/CallStateCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/CallStateCallback.kt index aef2019d3..02add640b 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/CallStateCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/CallStateCallback.kt @@ -7,8 +7,8 @@ import im.tox.tox4j.core.data.ToxFriendNumber interface CallStateCallback { /** * @param friendNumber The friend number this call state change is for. - * @param callState A set of ToxCallState values comprising the new call state. Although this is a - * Collection (therefore might actually be a List), this is effectively a Set. Any + * @param callState A set of ToxCallState values comprising the new call state. Although this is + * a Collection (therefore might actually be a List), this is effectively a Set. Any * [[ToxavFriendCallState]] value is contained exactly 0 or 1 times. */ fun callState( diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/VideoReceiveFrameCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/VideoReceiveFrameCallback.kt index 1009c9d44..4bf7e8fe1 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/VideoReceiveFrameCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/callbacks/VideoReceiveFrameCallback.kt @@ -12,15 +12,15 @@ interface VideoReceiveFrameCallback { * @param height Height of the frame in pixels. * @param y Y-plane. * @param u U-plane. - * @param v V-plane. The size of plane data is derived from width and height where Y = max(width, - * abs(yStride)) * height U = max(width/2, abs(uStride)) * (height/2) V = max(width/2, - * abs(vStride)) * (height/2). + * @param v V-plane. The size of plane data is derived from width and height where Y = + * max(width, abs(yStride)) * height U = max(width/2, abs(uStride)) * (height/2) V = + * max(width/2, abs(vStride)) * (height/2). * @param yStride Stride length for Y-plane. * @param uStride Stride length for U-plane. - * @param vStride Stride length for V-plane. Strides represent padding for each plane that may or - * may not be present. You must handle strides in your image processing code. Strides are - * negative if the image is bottom-up hence why you must abs() it when calculating plane buffer - * size. + * @param vStride Stride length for V-plane. Strides represent padding for each plane that may + * or may not be present. You must handle strides in your image processing code. Strides are + * negative if the image is bottom-up hence why you must abs() it when calculating plane + * buffer size. */ fun videoReceiveFrame( friendNumber: ToxFriendNumber, @@ -36,9 +36,9 @@ interface VideoReceiveFrameCallback { ): ToxCoreState = state /** - * An implementation may choose to keep the arrays to copy the data to around as an optimisation. - * If this method does not return [[null]], the arrays in the return value are passed to - * [[videoReceiveFrame]] as y, u, and v. + * An implementation may choose to keep the arrays to copy the data to around as an + * optimisation. If this method does not return [[null]], the arrays in the return value are + * passed to [[videoReceiveFrame]] as y, u, and v. */ fun videoFrameCachedYUV( height: Height, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavCallControl.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavCallControl.kt index b52cee2aa..79f8a5f41 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavCallControl.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavCallControl.kt @@ -1,50 +1,36 @@ package im.tox.tox4j.av.enums -/** - * Call control. - */ +/** Call control. */ enum class ToxavCallControl { /** - * Resume a previously paused call. Only valid if the pause was caused by this - * client, if not, this control is ignored. Not valid before the call is - * accepted. + * Resume a previously paused call. Only valid if the pause was caused by this client, if not, + * this control is ignored. Not valid before the call is accepted. */ RESUME, - /** - * Put a call on hold. Not valid before the call is accepted. - */ + /** Put a call on hold. Not valid before the call is accepted. */ PAUSE, - /** - * Reject a call if it was not answered, yet. Cancel a call after it was - * answered. - */ + /** Reject a call if it was not answered, yet. Cancel a call after it was answered. */ CANCEL, /** - * Request that the friend stops sending audio. Regardless of the friend's - * compliance, this will cause the {@link - * im.tox.tox4j.av.callbacks.AudioReceiveFrameCallback} event to stop being + * Request that the friend stops sending audio. Regardless of the friend's compliance, this will + * cause the {@link im.tox.tox4j.av.callbacks.AudioReceiveFrameCallback} event to stop being * triggered on receiving an audio frame from the friend. */ MUTE_AUDIO, - /** - * Calling this control will notify client to start sending audio again. - */ + /** Calling this control will notify client to start sending audio again. */ UNMUTE_AUDIO, /** - * Request that the friend stops sending video. Regardless of the friend's - * compliance, this will cause the {@link - * im.tox.tox4j.av.callbacks.VideoReceiveFrameCallback} event to stop being + * Request that the friend stops sending video. Regardless of the friend's compliance, this will + * cause the {@link im.tox.tox4j.av.callbacks.VideoReceiveFrameCallback} event to stop being * triggered on receiving an video frame from the friend. */ HIDE_VIDEO, - /** - * Calling this control will notify client to start sending video again. - */ + /** Calling this control will notify client to start sending video again. */ SHOW_VIDEO, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavFriendCallState.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavFriendCallState.kt index fe5fdd982..bc270d3d3 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavFriendCallState.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/enums/ToxavFriendCallState.kt @@ -1,41 +1,30 @@ package im.tox.tox4j.av.enums -/** - * Call state graph. - */ +/** Call state graph. */ enum class ToxavFriendCallState { /** - * Set by the AV core if an error occurred on the remote end or if friend - * timed out. This is the final state after which no more state - * transitions can occur for the call. This call state will never be triggered - * in combination with other call states. + * Set by the AV core if an error occurred on the remote end or if friend timed out. This is the + * final state after which no more state transitions can occur for the call. This call state + * will never be triggered in combination with other call states. */ ERROR, /** - * The call has finished. This is the final state after which no more state - * transitions can occur for the call. This call state will never be - * triggered in combination with other call states. + * The call has finished. This is the final state after which no more state transitions can + * occur for the call. This call state will never be triggered in combination with other call + * states. */ FINISHED, - /** - * The flag that marks that friend is sending audio. - */ + /** The flag that marks that friend is sending audio. */ SENDING_A, - /** - * The flag that marks that friend is sending video. - */ + /** The flag that marks that friend is sending video. */ SENDING_V, - /** - * The flag that marks that friend is receiving audio. - */ + /** The flag that marks that friend is receiving audio. */ ACCEPTING_A, - /** - * The flag that marks that friend is receiving video. - */ + /** The flag that marks that friend is receiving video. */ ACCEPTING_V, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavAnswerException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavAnswerException.kt index 816d33ac1..73ba1d097 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavAnswerException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavAnswerException.kt @@ -4,33 +4,26 @@ import im.tox.tox4j.exceptions.ToxException class ToxavAnswerException : ToxException { enum class Code { - /** - * Failed to initialise codecs for call session. - */ + /** Failed to initialise codecs for call session. */ CODEC_INITIALIZATION, /** - * The friend was valid, but they are not currently trying to initiate a call. - * This is also returned if this client is already in a call with the friend. + * The friend was valid, but they are not currently trying to initiate a call. This is also + * returned if this client is already in a call with the friend. */ FRIEND_NOT_CALLING, - /** - * The friend number did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * Audio or video bit rate is invalid. - */ + /** Audio or video bit rate is invalid. */ INVALID_BIT_RATE, - /** - * Synchronization error occurred. - */ + /** Synchronization error occurred. */ SYNC, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavBitRateSetException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavBitRateSetException.kt index 26d861438..76479f7cb 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavBitRateSetException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavBitRateSetException.kt @@ -4,27 +4,20 @@ import im.tox.tox4j.exceptions.ToxException class ToxavBitRateSetException : ToxException { enum class Code { - /** - * The friend_number passed did not designate a valid friend. - */ + /** The friend_number passed did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * This client is currently not in a call with the friend. - */ + /** This client is currently not in a call with the friend. */ FRIEND_NOT_IN_CALL, - /** - * The bit rate passed was not one of the supported values. - */ + /** The bit rate passed was not one of the supported values. */ INVALID_BIT_RATE, - /** - * Synchronization error occurred. - */ + /** Synchronization error occurred. */ SYNC, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallControlException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallControlException.kt index 35a968081..679a73a9f 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallControlException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallControlException.kt @@ -4,29 +4,26 @@ import im.tox.tox4j.exceptions.ToxException class ToxavCallControlException : ToxException { enum class Code { - /** - * The friend number did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, /** - * This client is currently not in a call with the friend. Before the call is - * answered, only CANCEL is a valid control + * This client is currently not in a call with the friend. Before the call is answered, only + * CANCEL is a valid control */ FRIEND_NOT_IN_CALL, /** - * Happens if user tried to pause an already paused call or if trying to - * resume a call that is not paused. + * Happens if user tried to pause an already paused call or if trying to resume a call that + * is not paused. */ INVALID_TRANSITION, - /** - * Synchronization error occurred. - */ + /** Synchronization error occurred. */ SYNC, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallException.kt index 000984c16..79c8f1eb9 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavCallException.kt @@ -4,37 +4,26 @@ import im.tox.tox4j.exceptions.ToxException class ToxavCallException : ToxException { enum class Code { - /** - * Attempted to call a friend while already in an audio or video call with them. - */ + /** Attempted to call a friend while already in an audio or video call with them. */ FRIEND_ALREADY_IN_CALL, - /** - * The friend was valid, but not currently connected. - */ + /** The friend was valid, but not currently connected. */ FRIEND_NOT_CONNECTED, - /** - * The friend number did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * Audio or video bit rate is invalid. - */ + /** Audio or video bit rate is invalid. */ INVALID_BIT_RATE, - /** - * A memory allocation error occurred. - */ + /** A memory allocation error occurred. */ MALLOC, - /** - * Synchronization error occurred. - */ + /** Synchronization error occurred. */ SYNC, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavNewException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavNewException.kt index 28cb969d5..9f1d90e0c 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavNewException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavNewException.kt @@ -5,28 +5,23 @@ import im.tox.tox4j.exceptions.ToxException class ToxavNewException : ToxException { enum class Code { - /** - * The ToxCore implementation passed was not compatible with this ToxAv implementation. - */ + /** The ToxCore implementation passed was not compatible with this ToxAv implementation. */ @JavaOnly INCOMPATIBLE, /** - * Memory allocation failure while trying to allocate structures required for - * the A/V session. + * Memory allocation failure while trying to allocate structures required for the A/V + * session. */ MALLOC, - /** - * Attempted to create a second session for the same Tox instance. - */ + /** Attempted to create a second session for the same Tox instance. */ MULTIPLE, - /** - * One of the arguments to the function was NULL when it was not expected. - */ + /** One of the arguments to the function was NULL when it was not expected. */ NULL, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavSendFrameException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavSendFrameException.kt index cae481399..d0dde5d21 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavSendFrameException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/av/exceptions/ToxavSendFrameException.kt @@ -4,45 +4,38 @@ import im.tox.tox4j.exceptions.ToxException class ToxavSendFrameException : ToxException { enum class Code { - /** - * The friend number did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * This client is currently not in a call with the friend. - */ + /** This client is currently not in a call with the friend. */ FRIEND_NOT_IN_CALL, /** - * One or more of the frame parameters was invalid. E.g. the resolution may be too - * small or too large, or the audio sampling rate may be unsupported. + * One or more of the frame parameters was invalid. E.g. the resolution may be too small or + * too large, or the audio sampling rate may be unsupported. */ INVALID, /** - * In case of video, one of Y, U, or V was NULL. In case of audio, the samples - * data pointer was NULL. + * In case of video, one of Y, U, or V was NULL. In case of audio, the samples data pointer + * was NULL. */ NULL, /** - * Either friend turned off audio or video receiving or we turned off sending - * for the said payload. + * Either friend turned off audio or video receiving or we turned off sending for the said + * payload. */ PAYLOAD_TYPE_DISABLED, - /** - * Failed to push frame through rtp interface. - */ + /** Failed to push frame through rtp interface. */ RTP_FAILED, - /** - * Synchronization error occurred. - */ + /** Synchronization error occurred. */ SYNC, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCore.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCore.kt index e2b823441..4664004a4 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCore.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCore.kt @@ -2,19 +2,42 @@ package im.tox.tox4j.core import im.tox.tox4j.core.callbacks.ToxCoreEventListener import im.tox.tox4j.core.data.Port +import im.tox.tox4j.core.data.ToxConferenceId +import im.tox.tox4j.core.data.ToxConferenceMessage +import im.tox.tox4j.core.data.ToxConferenceNumber +import im.tox.tox4j.core.data.ToxConferenceOfflinePeerNumber +import im.tox.tox4j.core.data.ToxConferencePeerName +import im.tox.tox4j.core.data.ToxConferencePeerNumber +import im.tox.tox4j.core.data.ToxConferenceTitle +import im.tox.tox4j.core.data.ToxConferenceUid import im.tox.tox4j.core.data.ToxFileId import im.tox.tox4j.core.data.ToxFilename import im.tox.tox4j.core.data.ToxFriendAddress import im.tox.tox4j.core.data.ToxFriendMessage +import im.tox.tox4j.core.data.ToxFriendMessageId import im.tox.tox4j.core.data.ToxFriendNumber import im.tox.tox4j.core.data.ToxFriendRequestMessage +import im.tox.tox4j.core.data.ToxGroupChatId +import im.tox.tox4j.core.data.ToxGroupMessage +import im.tox.tox4j.core.data.ToxGroupName +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPartMessage +import im.tox.tox4j.core.data.ToxGroupPassword +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.data.ToxGroupTopic import im.tox.tox4j.core.data.ToxLosslessPacket import im.tox.tox4j.core.data.ToxLossyPacket import im.tox.tox4j.core.data.ToxNickname import im.tox.tox4j.core.data.ToxPublicKey import im.tox.tox4j.core.data.ToxSecretKey import im.tox.tox4j.core.data.ToxStatusMessage +import im.tox.tox4j.core.enums.ToxConferenceType +import im.tox.tox4j.core.enums.ToxConnection import im.tox.tox4j.core.enums.ToxFileControl +import im.tox.tox4j.core.enums.ToxGroupPrivacyState +import im.tox.tox4j.core.enums.ToxGroupRole +import im.tox.tox4j.core.enums.ToxGroupTopicLock +import im.tox.tox4j.core.enums.ToxGroupVoiceState import im.tox.tox4j.core.enums.ToxMessageType import im.tox.tox4j.core.enums.ToxUserStatus import im.tox.tox4j.core.options.ToxOptions @@ -35,8 +58,8 @@ interface ToxCore : AutoCloseable { /** * Store all information associated with the tox instance to a byte array. * - * The data in the byte array can be used to create a new instance with [[load]] by passing it to - * the [[ToxOptions]] constructor. The concrete format in this serialised instance is + * The data in the byte array can be used to create a new instance with [[load]] by passing it + * to the [[ToxOptions]] constructor. The concrete format in this serialised instance is * implementation-defined. Passing save data created by one class to a different class may not * work. * @@ -77,8 +100,8 @@ interface ToxCore : AutoCloseable { /** * Bootstrap into the tox network. * - * Sends a "get nodes" request to the given bootstrap node with IP, port, and public key to setup - * connections. + * Sends a "get nodes" request to the given bootstrap node with IP, port, and public key to + * setup connections. * * This function will only attempt to connect to the node using UDP. If you want to additionally * attempt to connect using TCP, use [[addTcpRelay]] together with this function. @@ -97,8 +120,8 @@ interface ToxCore : AutoCloseable { /** * Connect to a TCP relay to forward traffic. * - * This function can be used to initiate TCP connections to different ports on the same bootstrap - * node, or to add TCP relays without using them as bootstrap nodes. + * This function can be used to initiate TCP connections to different ports on the same + * bootstrap node, or to add TCP relays without using them as bootstrap nodes. * * @param address the hostname, or an IPv4/IPv6 address of the node. * @param port the TCP port the node is running a relay on. @@ -142,7 +165,8 @@ interface ToxCore : AutoCloseable { val getDhtId: ToxPublicKey /** - * Get the time in milliseconds until [[iterate]] should be called again for optimal performance. + * Get the time in milliseconds until [[iterate]] should be called again for optimal + * performance. * * @return the time in milliseconds until [[iterate]] should be called again. */ @@ -175,8 +199,8 @@ interface ToxCore : AutoCloseable { /** * Set the 4-byte nospam part of the address. * - * Setting the nospam makes it impossible for others to send us friend requests that contained the - * old nospam number. + * Setting the nospam makes it impossible for others to send us friend requests that contained + * the old nospam number. * * @param nospam the new nospam number. */ @@ -239,13 +263,13 @@ interface ToxCore : AutoCloseable { * Add a friend to the friend list and send a friend request. * * A friend request message must be at least 1 byte long and at most - * [ [ToxCoreConstants.MAX_FRIEND_REQUEST_LENGTH]]. + * [[ToxCoreConstants.MAX_FRIEND_REQUEST_LENGTH]]. * * Friend numbers are unique identifiers used in all functions that operate on friends. Once - * added, a friend number is stable for the lifetime of the Tox object. After saving the state and - * reloading it, the friend numbers may not be the same as before. Deleting a friend creates a gap - * in the friend number set, which is filled by the next adding of a friend. Any pattern in friend - * numbers should not be relied on. + * added, a friend number is stable for the lifetime of the Tox object. After saving the state + * and reloading it, the friend numbers may not be the same as before. Deleting a friend creates + * a gap in the friend number set, which is filled by the next adding of a friend. Any pattern + * in friend numbers should not be relied on. * * If more than [[Int.MaxValue]] friends are added, this function throws an exception. * @@ -270,15 +294,16 @@ interface ToxCore : AutoCloseable { /** * Add a friend without sending a friend request. * - * This function is used to add a friend in response to a friend request. If the client receives a - * friend request, it can be reasonably sure that the other client added this client as a friend, - * eliminating the need for a friend request. + * This function is used to add a friend in response to a friend request. If the client receives + * a friend request, it can be reasonably sure that the other client added this client as a + * friend, eliminating the need for a friend request. * * This function is also useful in a situation where both instances are controlled by the same * entity, so that this entity can perform the mutual friend adding. In this case, there is no * need for a friend request, either. * - * @param publicKey the Public Key to add as a friend ([[ToxCoreConstants.PUBLIC_KEY_SIZE]] bytes). + * @param publicKey the Public Key to add as a friend ([[ToxCoreConstants.PUBLIC_KEY_SIZE]] + * bytes). * @return the new friend's friend number. * @throws ToxFriendAddException * @throws IllegalArgumentException @@ -340,7 +365,8 @@ interface ToxCore : AutoCloseable { /** * Get an array of [[ToxFriendNumber]] objects with the same values as [[getFriendList]]. * - * This method exists for Java compatibility, because [[getFriendList]] must return an int array. + * This method exists for Java compatibility, because [[getFriendList]] must return an int + * array. * * @return [[getFriendList]] mapped to [[ToxFriendNumber]]. */ @@ -366,23 +392,21 @@ interface ToxCore : AutoCloseable { * * This function creates a chat message packet and pushes it into the send queue. * - * The message length may not exceed [[ToxCoreConstants.MAX_MESSAGE_LENGTH]]. Larger messages must - * be split by the client and sent as separate messages. Other clients can then reassemble the - * fragments. Messages may not be empty. + * The message length may not exceed [[ToxCoreConstants.MAX_MESSAGE_LENGTH]]. Larger messages + * must be split by the client and sent as separate messages. Other clients can then reassemble + * the fragments. Messages may not be empty. * * The return value of this function is the message ID. If a read receipt is received, the * triggered [[FriendReadReceiptCallback]] event will be passed this message ID. * * Message IDs are unique per friend per instance. The first message ID is 0. Message IDs are - * incremented by 1 each time a message is sent. If [[Int.MaxValue]] messages were sent, the next - * message ID is [[Int.MinValue]]. + * incremented by 1 each time a message is sent. If [[Int.MaxValue]] messages were sent, the + * next message ID is [[Int.MinValue]]. * * Message IDs are not stored in the array returned by [[getSavedata]]. * * @param friendNumber The friend number of the friend to send the message to. * @param messageType Message type (normal, action, ...). - * @param timeDelta The time between composition (user created the message) and calling this - * function. * @param message The message text * @return the message ID. * @throws ToxFriendSendMessageException @@ -390,9 +414,8 @@ interface ToxCore : AutoCloseable { fun friendSendMessage( friendNumber: ToxFriendNumber, messageType: ToxMessageType, - timeDelta: Int, message: ToxFriendMessage, - ): Int + ): ToxFriendMessageId /** * Sends a file control command to a friend for a given file transfer. @@ -442,16 +465,18 @@ interface ToxCore : AutoCloseable { /** * Send a file transmission request. * - * Maximum filename length is [[ToxCoreConstants.MAX_FILENAME_LENGTH]] bytes. The filename should - * generally just be a file name, not a path with directory names. + * Maximum filename length is [[ToxCoreConstants.MAX_FILENAME_LENGTH]] bytes. The filename + * should generally just be a file name, not a path with directory names. * - * If a non-negative file size is provided, it can be used by both sides to determine the sending - * progress. File size can be set to a negative value for streaming data of unknown size. + * If a non-negative file size is provided, it can be used by both sides to determine the + * sending progress. File size can be set to a negative value for streaming data of unknown + * size. * - * File transmission occurs in chunks, which are requested through the [[FileChunkRequestCallback] - * ] event. + * File transmission occurs in chunks, which are requested through the + * [[FileChunkRequestCallback] ] event. * - * When a friend goes offline, all file transfers associated with the friend are purged from core. + * When a friend goes offline, all file transfers associated with the friend are purged from + * core. * * If the file contents change during a transfer, the behaviour is unspecified in general. What * will actually happen depends on the mode in which the file was modified and how the client @@ -501,8 +526,10 @@ interface ToxCore : AutoCloseable { * The friend number of the friend the file send request should be sent to. * * @param kind The meaning of the file to be sent. - * @param fileSize Size in bytes of the file the client wants to send, -1 if unknown or streaming. - * @param fileId A file identifier of length [[ToxCoreConstants.FILE_ID_LENGTH]] that can be used to + * @param fileSize Size in bytes of the file the client wants to send, -1 if unknown or + * streaming. + * @param fileId A file identifier of length [[ToxCoreConstants.FILE_ID_LENGTH]] that can be + * used to * * ``` * uniquely identify file transfers across core restarts. If empty, a random one will @@ -523,6 +550,7 @@ interface ToxCore : AutoCloseable { * number is per friend. File numbers are reused after a transfer terminates. * Any pattern in file numbers should not be relied on. * ``` + * * @throws ToxFileSendException */ fun fileSend( @@ -537,11 +565,11 @@ interface ToxCore : AutoCloseable { * Send a chunk of file data to a friend. * * This function is called in response to the [[FileChunkRequestCallback]] callback. The length - * parameter should be equal to the one received though the callback. If it is zero, the transfer - * is assumed complete. For files with known size, Core will know that the transfer is complete - * after the last byte has been received, so it is not necessary (though not harmful) to send a - * zero-length chunk to terminate. For streams, core will know that the transfer is finished if a - * chunk with length less than the length requested in the callback is sent. + * parameter should be equal to the one received though the callback. If it is zero, the + * transfer is assumed complete. For files with known size, Core will know that the transfer is + * complete after the last byte has been received, so it is not necessary (though not harmful) + * to send a zero-length chunk to terminate. For streams, core will know that the transfer is + * finished if a chunk with length less than the length requested in the callback is sent. * * @param friendNumber The friend number of the receiving friend for this file. * @param fileNumber The file transfer identifier returned by [[fileSend]]. @@ -563,8 +591,8 @@ interface ToxCore : AutoCloseable { * [ [ToxCoreConstants.MAX_CUSTOM_PACKET_SIZE]]. * * Lossy packets behave like UDP packets, meaning they might never reach the other side or might - * arrive more than once (if someone is messing with the connection) or might arrive in the wrong - * order. + * arrive more than once (if someone is messing with the connection) or might arrive in the + * wrong order. * * Unless latency is an issue, it is recommended that you use lossless custom packets instead. * @@ -583,8 +611,8 @@ interface ToxCore : AutoCloseable { * The first byte of data must be in the range 160-191. Maximum length of a custom packet is * [ [ToxCoreConstants.MAX_CUSTOM_PACKET_SIZE]]. * - * Lossless packet behaviour is comparable to TCP (reliability, arrive in order) but with packets - * instead of a stream. + * Lossless packet behaviour is comparable to TCP (reliability, arrive in order) but with + * packets instead of a stream. * * @param friendNumber The friend number of the friend this lossless packet should be sent to. * @param data A byte array containing the packet data including packet id. @@ -594,4 +622,242 @@ interface ToxCore : AutoCloseable { friendNumber: ToxFriendNumber, data: ToxLosslessPacket, ): Unit + + fun conferenceNew(): ToxConferenceNumber + + fun conferenceDelete(conferenceNumber: ToxConferenceNumber): Unit + + fun conferencePeerCount(conferenceNumber: ToxConferenceNumber): Int + + fun conferencePeerGetName( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + ): ToxConferencePeerName + + fun conferencePeerGetPublicKey( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + ): ToxPublicKey + + fun conferencePeerNumberIsOurs( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + ): Boolean + + fun conferenceOfflinePeerCount(conferenceNumber: ToxConferenceNumber): Int + + fun conferenceOfflinePeerGetName( + conferenceNumber: ToxConferenceNumber, + offlinePeerNumber: ToxConferenceOfflinePeerNumber, + ): ToxConferencePeerName + + fun conferenceOfflinePeerGetPublicKey( + conferenceNumber: ToxConferenceNumber, + offlinePeerNumber: ToxConferenceOfflinePeerNumber, + ): ToxPublicKey + + fun conferenceOfflinePeerGetLastActive( + conferenceNumber: ToxConferenceNumber, + offlinePeerNumber: ToxConferenceOfflinePeerNumber, + ): Long + + fun conferenceSetMaxOffline( + conferenceNumber: ToxConferenceNumber, + maxOffline: Int, + ): Unit + + fun conferenceInvite( + friendNumber: ToxFriendNumber, + conferenceNumber: ToxConferenceNumber, + ): Unit + + fun conferenceJoin( + friendNumber: ToxFriendNumber, + cookie: ByteArray, + ): ToxConferenceNumber + + fun conferenceSendMessage( + conferenceNumber: ToxConferenceNumber, + messageType: ToxMessageType, + message: ToxConferenceMessage, + ): Unit + + fun conferenceGetTitle(conferenceNumber: ToxConferenceNumber): ToxConferenceTitle + + fun conferenceSetTitle( + conferenceNumber: ToxConferenceNumber, + title: ToxConferenceTitle, + ): Unit + + val conferenceGetChatlist: IntArray + + val conferenceGetChatNumbers: List + get() = conferenceGetChatlist.map { ToxConferenceNumber(it) } + + fun conferenceGetType(conferenceNumber: ToxConferenceNumber): ToxConferenceType + + fun conferenceGetId(conferenceNumber: ToxConferenceNumber): ToxConferenceId + + fun conferenceById(conferenceId: ToxConferenceId): ToxConferenceNumber + + fun conferenceGetUid(conferenceNumber: ToxConferenceNumber): ToxConferenceUid + + fun conferenceByUid(conferenceUid: ToxConferenceUid): ToxConferenceNumber + + fun groupNew( + privacyState: ToxGroupPrivacyState, + groupName: ToxGroupName, + name: ToxGroupName, + ): ToxGroupNumber + + fun groupJoin( + chatId: ToxGroupChatId, + name: ToxGroupName, + password: ToxGroupPassword, + ): ToxGroupNumber + + fun groupIsConnected(groupNumber: ToxGroupNumber): Boolean + + fun groupDisconnect(groupNumber: ToxGroupNumber): Unit + + fun groupReconnect(groupNumber: ToxGroupNumber): Unit + + fun groupLeave(groupNumber: ToxGroupNumber, partMessage: ToxGroupPartMessage): Unit + + fun groupSelfSetName(groupNumber: ToxGroupNumber, name: ToxGroupName): Unit + + fun groupSelfGetName(groupNumber: ToxGroupNumber): ToxGroupName + + fun groupSelfSetStatus(groupNumber: ToxGroupNumber, status: ToxUserStatus): Unit + + fun groupSelfGetStatus(groupNumber: ToxGroupNumber): ToxUserStatus + + fun groupSelfGetRole(groupNumber: ToxGroupNumber): ToxGroupRole + + fun groupSelfGetPeerId(groupNumber: ToxGroupNumber): ToxGroupPeerNumber + + fun groupSelfGetPublicKey(groupNumber: ToxGroupNumber): ToxPublicKey + + fun groupPeerGetName( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxGroupName + + fun groupPeerGetStatus( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxUserStatus + + fun groupPeerGetRole( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxGroupRole + + fun groupPeerGetConnectionStatus( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxConnection + + fun groupPeerGetPublicKey( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxPublicKey + + fun groupSetTopic(groupNumber: ToxGroupNumber, topic: ToxGroupTopic): Unit + + fun groupGetTopic(groupNumber: ToxGroupNumber): ToxGroupTopic + + fun groupGetName(groupNumber: ToxGroupNumber): ToxGroupName + + fun groupGetChatId(groupNumber: ToxGroupNumber): ToxGroupChatId + + fun groupGetPrivacyState(groupNumber: ToxGroupNumber): ToxGroupPrivacyState + + fun groupGetVoiceState(groupNumber: ToxGroupNumber): ToxGroupVoiceState + + fun groupGetTopicLock(groupNumber: ToxGroupNumber): ToxGroupTopicLock + + fun groupGetPeerLimit(groupNumber: ToxGroupNumber): Int + + fun groupGetPassword(groupNumber: ToxGroupNumber): ToxGroupPassword + + fun groupSendMessage( + groupNumber: ToxGroupNumber, + messageType: ToxMessageType, + message: ToxGroupMessage, + ): Int + + fun groupSendPrivateMessage( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + messageType: ToxMessageType, + message: ToxGroupMessage, + ): Int + + fun groupSendCustomPacket( + groupNumber: ToxGroupNumber, + lossless: Boolean, + data: ByteArray, + ): Unit + + fun groupSendCustomPrivatePacket( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + lossless: Boolean, + data: ByteArray, + ): Unit + + fun groupInviteFriend( + groupNumber: ToxGroupNumber, + friendNumber: ToxFriendNumber, + ): Unit + + fun groupInviteAccept( + friendNumber: ToxFriendNumber, + inviteData: ByteArray, + name: ToxGroupName, + password: ToxGroupPassword, + ): ToxGroupNumber + + fun groupSetPassword( + groupNumber: ToxGroupNumber, + password: ToxGroupPassword, + ): Unit + + fun groupSetTopicLock( + groupNumber: ToxGroupNumber, + topicLock: ToxGroupTopicLock, + ): Unit + + fun groupSetVoiceState( + groupNumber: ToxGroupNumber, + voiceState: ToxGroupVoiceState, + ): Unit + + fun groupSetPrivacyState( + groupNumber: ToxGroupNumber, + privacyState: ToxGroupPrivacyState, + ): Unit + + fun groupSetPeerLimit( + groupNumber: ToxGroupNumber, + peerLimit: Int, + ): Unit + + fun groupSetIgnore( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ignore: Boolean, + ): Unit + + fun groupSetRole( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + role: ToxGroupRole, + ): Unit + + fun groupKickPeer( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): Unit } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCoreConstants.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCoreConstants.kt index e6cc4f687..f6493d306 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCoreConstants.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/ToxCoreConstants.kt @@ -13,8 +13,8 @@ object ToxCoreConstants { * The size of a Tox address in bytes. Tox addresses are in the format * [Public Key ([ [PUBLIC_KEY_SIZE]] bytes)][nospam (4 bytes)][checksum (2 bytes)]. * - * The checksum is computed over the Public Key and the nospam value. The first byte is an XOR of - * all the odd bytes, the second byte is an XOR of all the even bytes of the Public Key and + * The checksum is computed over the Public Key and the nospam value. The first byte is an XOR + * of all the odd bytes, the second byte is an XOR of all the even bytes of the Public Key and * nospam. */ const val ADDRESS_SIZE = PUBLIC_KEY_SIZE + 4 + 2 @@ -38,8 +38,8 @@ object ToxCoreConstants { const val MAX_FILENAME_LENGTH = 255 /** - * Maximum hostname length. This is determined by calling `getconf HOST_NAME_MAX` on the console. - * The value presented here is valid for most systems. + * Maximum hostname length. This is determined by calling `getconf HOST_NAME_MAX` on the + * console. The value presented here is valid for most systems. */ const val MAX_HOSTNAME_LENGTH = 255 diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceConnectedCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceConnectedCallback.kt new file mode 100644 index 000000000..d9f224a10 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceConnectedCallback.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxConferenceNumber + +/** + * This event is triggered when the client successfully connects to a conference after joining it + * with the tox_conference_join function. + */ +interface ConferenceConnectedCallback { + /** + * @param conferenceNumber The conference number of the conference to which we have connected. + */ + fun conferenceConnected( + conferenceNumber: ToxConferenceNumber, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceInviteCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceInviteCallback.kt new file mode 100644 index 000000000..9025d7230 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceInviteCallback.kt @@ -0,0 +1,19 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxFriendNumber +import im.tox.tox4j.core.enums.ToxConferenceType + +/** This event is triggered when the client is invited to join a conference. */ +interface ConferenceInviteCallback { + /** + * @param friendNumber The friend who invited us. + * @param type The conference type (text only or audio/video). + * @param cookie A piece of data of variable length required to join the conference. + */ + fun conferenceInvite( + friendNumber: ToxFriendNumber, + type: ToxConferenceType, + cookie: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceMessageCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceMessageCallback.kt new file mode 100644 index 000000000..87d7074e8 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceMessageCallback.kt @@ -0,0 +1,22 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxConferenceNumber +import im.tox.tox4j.core.data.ToxConferencePeerNumber +import im.tox.tox4j.core.enums.ToxMessageType + +/** This event is triggered when the client receives a conference message. */ +interface ConferenceMessageCallback { + /** + * @param conferenceNumber The conference number of the conference the message is intended for. + * @param peerNumber The ID of the peer who sent the message. + * @param type The type of message (normal, action, ...). + * @param message The message data. + */ + fun conferenceMessage( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + type: ToxMessageType, + message: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferencePeerListChangedCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferencePeerListChangedCallback.kt new file mode 100644 index 000000000..617c75124 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferencePeerListChangedCallback.kt @@ -0,0 +1,12 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxConferenceNumber + +/** This event is triggered when a peer joins or leaves the conference. */ +interface ConferencePeerListChangedCallback { + /** @param conferenceNumber The conference number of the conference the peer is in. */ + fun conferencePeerListChanged( + conferenceNumber: ToxConferenceNumber, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferencePeerNameCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferencePeerNameCallback.kt new file mode 100644 index 000000000..23d58d4cc --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferencePeerNameCallback.kt @@ -0,0 +1,19 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxConferenceNumber +import im.tox.tox4j.core.data.ToxConferencePeerNumber + +/** This event is triggered when a peer changes their name. */ +interface ConferencePeerNameCallback { + /** + * @param conferenceNumber The conference number of the conference the peer is in. + * @param peerNumber The ID of the peer who changed their nickname. + * @param name A byte array containing the new nickname. + */ + fun conferencePeerName( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + name: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceTitleCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceTitleCallback.kt new file mode 100644 index 000000000..6aa0f8d2e --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ConferenceTitleCallback.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxConferenceNumber +import im.tox.tox4j.core.data.ToxConferencePeerNumber + +/** This event is triggered when a peer changes the conference title. */ +interface ConferenceTitleCallback { + /** + * @param conferenceNumber The conference number of the conference the title change is intended + * for. + * @param peerNumber The ID of the peer who changed the title. + * @param title The title data. + */ + fun conferenceTitle( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + title: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileChunkRequestCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileChunkRequestCallback.kt index 79559430d..14703d341 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileChunkRequestCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileChunkRequestCallback.kt @@ -2,7 +2,7 @@ package im.tox.tox4j.core.callbacks import im.tox.tox4j.core.data.ToxFriendNumber -/** This event is triggered when Core is ready to send more file data. */ +/** This event is triggered when Tox is ready to send more file data. */ interface FileChunkRequestCallback { /** * If the length parameter is 0, the file transfer is finished, and the client's resources @@ -12,17 +12,16 @@ interface FileChunkRequestCallback { * If the requested position is not equal to the client's idea of the current file or stream * position, it will need to seek. In case of read-once streams, the client should keep the last * read chunk so that a seek back can be supported. A seek-back only ever needs to read from the - * last requested chunk. This happens when a chunk was requested, but the send failed. A seek-back - * request can occur an arbitrary number of times for any given chunk. + * last requested chunk. This happens when a chunk was requested, but the send failed. A + * seek-back request can occur an arbitrary number of times for any given chunk. * * In response to receiving this callback, the client should call the function - * [ [ToxCore.fileSendChunk]] with the requested chunk. If the number of bytes sent through that - * function is zero, the file transfer is assumed complete. A client must send the full length of - * data requested with this callback. + * `tox_file_send_chunk` with the requested chunk. If the number of bytes sent through that + * function is zero, the file transfer is assumed complete. A client must send the full length + * of data requested with this callback. * * @param friendNumber The friend number of the receiving friend for this file. - * @param fileNumber The file transfer identifier returned by { @link - * im.tox.tox4j.core.ToxCore#fileSend}. + * @param fileNumber The file transfer identifier returned by tox_file_send. * @param position The file or stream position from which to continue reading. * @param length The number of bytes requested for the current chunk. */ diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvCallback.kt index 6bc4fb5a7..14a957e58 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvCallback.kt @@ -2,22 +2,22 @@ package im.tox.tox4j.core.callbacks import im.tox.tox4j.core.data.ToxFilename import im.tox.tox4j.core.data.ToxFriendNumber -import im.tox.tox4j.core.enums.ToxFileControl /** This event is triggered when a file transfer request is received. */ interface FileRecvCallback { /** * The client should acquire resources to be associated with the file transfer. Incoming file - * transfers start in the PAUSED state. After this callback returns, a transfer can be rejected by - * sending a [[ToxFileControl.CANCEL]] control command before any other control commands. It can - * be accepted by sending [[ToxFileControl.RESUME]]. + * transfers start in the PAUSED state. After this callback returns, a transfer can be rejected + * by sending a TOX_FILE_CONTROL_CANCEL control command before any other control commands. It + * can be accepted by sending TOX_FILE_CONTROL_RESUME. * * @param friendNumber The friend number of the friend who is sending the file transfer request. * @param fileNumber The friend-specific file number the data received is associated with. - * @param kind The meaning of the file to be sent. - * @param fileSize Size in bytes of the file the client wants to send, -1 if unknown or streaming. - * @param filename Name of the file. May not be the actual name. This name was sent along with the - * file send request. + * @param kind The meaning of the file that was sent. + * @param fileSize Size in bytes of the file the client wants to send, UINT64_MAX if unknown or + * streaming. + * @param filename Name of the file. Does not need to be the actual name. This name will be sent + * along with the file send request. */ fun fileRecv( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvChunkCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvChunkCallback.kt index e70c47d3b..b40383836 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvChunkCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvChunkCallback.kt @@ -9,12 +9,12 @@ import im.tox.tox4j.core.data.ToxFriendNumber interface FileRecvChunkCallback { /** * When length is 0, the transfer is finished and the client should release the resources it - * acquired for the transfer. After a call with length = 0, the file number can be reused for new - * file transfers. + * acquired for the transfer. After a call with length = 0, the file number can be reused for + * new file transfers. * - * If position is equal to file_size (received in the [[FileRecvCallback]] callback) when the - * transfer finishes, the file was received completely. Otherwise, if fileSize was negative, - * streaming ended successfully when length is 0. + * If position is equal to file_size (received in the file_receive callback) when the transfer + * finishes, the file was received completely. Otherwise, if file_size was UINT64_MAX, streaming + * ended successfully when length is 0. * * @param friendNumber The friend number of the friend who is sending the file. * @param fileNumber The friend-specific file number the data received is associated with. diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvControlCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvControlCallback.kt index 502c22089..64e31a22e 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvControlCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FileRecvControlCallback.kt @@ -6,12 +6,11 @@ import im.tox.tox4j.core.enums.ToxFileControl /** This event is triggered when a file control command is received from a friend. */ interface FileRecvControlCallback { /** - * When receiving [[ToxFileControl.CANCEL]], the client should release the resources associated - * with the file number and consider the transfer failed. - * * @param friendNumber The friend number of the friend who is sending the file. * @param fileNumber The friend-specific file number the data received is associated with. * @param control The file control command received. + * @brief When receiving TOX_FILE_CONTROL_CANCEL, the client should release the resources + * associated with the file number and consider the transfer failed. */ fun fileRecvControl( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendConnectionStatusCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendConnectionStatusCallback.kt index ff2b5ce0b..bd370fadf 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendConnectionStatusCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendConnectionStatusCallback.kt @@ -4,8 +4,8 @@ import im.tox.tox4j.core.data.ToxFriendNumber import im.tox.tox4j.core.enums.ToxConnection /** - * This event is triggered when a friend goes offline after having been online, when a friend goes - * online, or when the connection type (TCP/UDP) changes. + * This event is triggered when a friend goes offline after having been online, or when a friend + * goes online. * * This callback is not called when adding friends. It is assumed that when adding friends, their * connection status is initially offline. @@ -13,7 +13,8 @@ import im.tox.tox4j.core.enums.ToxConnection interface FriendConnectionStatusCallback { /** * @param friendNumber The friend number of the friend whose connection status changed. - * @param connectionStatus The new connection status. + * @param connectionStatus The result of calling tox_friend_get_connection_status on the passed + * friendNumber. */ fun friendConnectionStatus( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLosslessPacketCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLosslessPacketCallback.kt index 06623b62c..47c7b02ab 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLosslessPacketCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLosslessPacketCallback.kt @@ -3,11 +3,11 @@ package im.tox.tox4j.core.callbacks import im.tox.tox4j.core.data.ToxFriendNumber import im.tox.tox4j.core.data.ToxLosslessPacket -/** This event is triggered when a custom lossless packet arrives from a friend. */ +/** This event is triggered when a lossless packet is received from a friend. */ interface FriendLosslessPacketCallback { /** - * @param friendNumber The friend number of the friend who sent a lossless packet. - * @param data A byte array containing the received packet data. The first byte is the packet id. + * @param friendNumber The friend number of the friend who sent the packet. + * @param data A byte array containing the received packet data. */ fun friendLosslessPacket( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLossyPacketCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLossyPacketCallback.kt index a6db2d44b..225b7d87e 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLossyPacketCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendLossyPacketCallback.kt @@ -3,11 +3,11 @@ package im.tox.tox4j.core.callbacks import im.tox.tox4j.core.data.ToxFriendNumber import im.tox.tox4j.core.data.ToxLossyPacket -/** This event is triggered when a custom lossy packet arrives from a friend. */ +/** This event is triggered when a lossy packet is received from a friend. */ interface FriendLossyPacketCallback { /** * @param friendNumber The friend number of the friend who sent a lossy packet. - * @param data A byte array containing the received packet data. The first byte is the packet id. + * @param data A byte array containing the received packet data. */ fun friendLossyPacket( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendMessageCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendMessageCallback.kt index 4a4f2a339..8b1b8b554 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendMessageCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendMessageCallback.kt @@ -8,23 +8,12 @@ import im.tox.tox4j.core.enums.ToxMessageType interface FriendMessageCallback { /** * @param friendNumber The friend number of the friend who sent the message. - * @param messageType Message type (normal, action, ...). - * @param timeDelta A delta in seconds between when the message was composed - * - * ``` - * and when it is being transmitted. For messages that are sent immediately, - * it will be 0. If a message was written and couldn't be sent immediately - * (due to a connection failure, for example), the timeDelta is an - * approximation of when it was composed. - * @param message - * ``` - * - * The message data they sent. + * @param type The type of the message (normal, action, ...). + * @param message The message data they sent. */ fun friendMessage( friendNumber: ToxFriendNumber, - messageType: ToxMessageType, - timeDelta: Int, + type: ToxMessageType, message: ToxFriendMessage, state: ToxCoreState, ): ToxCoreState = state diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendNameCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendNameCallback.kt index 0b496a8be..7721fb730 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendNameCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendNameCallback.kt @@ -7,7 +7,8 @@ import im.tox.tox4j.core.data.ToxNickname interface FriendNameCallback { /** * @param friendNumber The friend number of the friend whose name changed. - * @param name The new nickname. + * @param name A byte array containing the same data as tox_friend_get_name would write to its + * `name` parameter. */ fun friendName( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendReadReceiptCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendReadReceiptCallback.kt index c2a01c373..ca2429b2b 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendReadReceiptCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendReadReceiptCallback.kt @@ -1,20 +1,21 @@ package im.tox.tox4j.core.callbacks +import im.tox.tox4j.core.data.ToxFriendMessageId import im.tox.tox4j.core.data.ToxFriendNumber /** - * This event is triggered when the friend receives the message sent with - * [ [ToxCore.friendSendMessage]] with the corresponding message ID. + * This event is triggered when the friend receives the message sent with tox_friend_send_message + * with the corresponding message ID. */ interface FriendReadReceiptCallback { /** * @param friendNumber The friend number of the friend who received the message. - * @param messageId The message ID as returned from [[ToxCore.friendSendMessage]] corresponding to - * the message sent. + * @param messageId The message ID as returned from tox_friend_send_message corresponding to the + * message sent. */ fun friendReadReceipt( friendNumber: ToxFriendNumber, - messageId: Int, + messageId: ToxFriendMessageId, state: ToxCoreState, ): ToxCoreState = state } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendRequestCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendRequestCallback.kt index 15d4db838..c508b8b0f 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendRequestCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendRequestCallback.kt @@ -7,18 +7,10 @@ import im.tox.tox4j.core.data.ToxPublicKey interface FriendRequestCallback { /** * @param publicKey The Public Key of the user who sent the friend request. - * @param timeDelta A delta in seconds between when the message was composed - * - * ``` - * and when it is being transmitted. - * @param message - * ``` - * - * The message they sent along with the request. + * @param message The message they sent along with the request. */ fun friendRequest( publicKey: ToxPublicKey, - timeDelta: Int, message: ToxFriendRequestMessage, state: ToxCoreState, ): ToxCoreState = state diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendStatusMessageCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendStatusMessageCallback.kt index aa87bf2fe..245333881 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendStatusMessageCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendStatusMessageCallback.kt @@ -7,7 +7,8 @@ import im.tox.tox4j.core.data.ToxStatusMessage interface FriendStatusMessageCallback { /** * @param friendNumber The friend number of the friend whose status message changed. - * @param message The new status message. + * @param message A byte array containing the same data as tox_friend_get_status_message would + * write to its `status_message` parameter. */ fun friendStatusMessage( friendNumber: ToxFriendNumber, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendTypingCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendTypingCallback.kt index 249d5f2a7..351cae356 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendTypingCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/FriendTypingCallback.kt @@ -6,11 +6,11 @@ import im.tox.tox4j.core.data.ToxFriendNumber interface FriendTypingCallback { /** * @param friendNumber The friend number of the friend who started or stopped typing. - * @param isTyping Whether the friend started (true) or stopped (false) typing. + * @param typing Whether the friend is currently typing. */ fun friendTyping( friendNumber: ToxFriendNumber, - isTyping: Boolean, + typing: Boolean, state: ToxCoreState, ): ToxCoreState = state } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupCustomPacketCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupCustomPacketCallback.kt new file mode 100644 index 000000000..b84a21626 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupCustomPacketCallback.kt @@ -0,0 +1,19 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber + +/** This event is triggered when the client receives a custom packet. */ +interface GroupCustomPacketCallback { + /** + * @param groupNumber The group number of the group the packet is intended for. + * @param peerId The ID of the peer who sent the packet. + * @param data The packet data. + */ + fun groupCustomPacket( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + data: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupCustomPrivatePacketCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupCustomPrivatePacketCallback.kt new file mode 100644 index 000000000..95c8cf090 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupCustomPrivatePacketCallback.kt @@ -0,0 +1,19 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber + +/** This event is triggered when the client receives a custom private packet. */ +interface GroupCustomPrivatePacketCallback { + /** + * @param groupNumber The group number of the group the packet is intended for. + * @param peerId The ID of the peer who sent the packet. + * @param data The packet data. + */ + fun groupCustomPrivatePacket( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + data: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupInviteCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupInviteCallback.kt new file mode 100644 index 000000000..35d16d68e --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupInviteCallback.kt @@ -0,0 +1,21 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxFriendNumber + +/** + * This event is triggered when the client receives a group invite from a friend. The client must + * store invite_data which is used to join the group via tox_group_invite_accept. + */ +interface GroupInviteCallback { + /** + * @param friendNumber The friend number of the contact who sent the invite. + * @param inviteData The invite data. + * @param groupName The name of the group. + */ + fun groupInvite( + friendNumber: ToxFriendNumber, + inviteData: ByteArray, + groupName: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupJoinFailCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupJoinFailCallback.kt new file mode 100644 index 000000000..31aa42861 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupJoinFailCallback.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.enums.ToxGroupJoinFail + +/** This event is triggered when the client fails to join a group. */ +interface GroupJoinFailCallback { + /** + * @param groupNumber The group number of the group for which the join has failed. + * @param failType The type of group rejection. + */ + fun groupJoinFail( + groupNumber: ToxGroupNumber, + failType: ToxGroupJoinFail, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupMessageCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupMessageCallback.kt new file mode 100644 index 000000000..48a714f92 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupMessageCallback.kt @@ -0,0 +1,26 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupMessageId +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.enums.ToxMessageType + +/** This event is triggered when the client receives a group message. */ +interface GroupMessageCallback { + /** + * @param groupNumber The group number of the group the message is intended for. + * @param peerId The ID of the peer who sent the message. + * @param messageType The type of message (normal, action, ...). + * @param message The message data. + * @param messageId A pseudo message id that clients can use to uniquely identify this group + * message. + */ + fun groupMessage( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + messageType: ToxMessageType, + message: ByteArray, + messageId: ToxGroupMessageId, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupModerationCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupModerationCallback.kt new file mode 100644 index 000000000..5cf4a1d59 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupModerationCallback.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.enums.ToxGroupModEvent + +/** + * This event is triggered when a moderator or founder executes a moderation event, with the + * exception of the peer who initiates the event. It is also triggered when the observer and + * moderator lists are silently modified (this may occur during group syncing). + * + * If either peer id does not designate a valid peer in the group chat, the client should manually + * update all peer roles. + */ +interface GroupModerationCallback { + /** + * @param groupNumber The group number of the group the event is intended for. + * @param sourcePeerId The ID of the peer who initiated the event. + * @param targetPeerId The ID of the peer who is the target of the event. + * @param modType The type of event. + */ + fun groupModeration( + groupNumber: ToxGroupNumber, + sourcePeerId: ToxGroupPeerNumber, + targetPeerId: ToxGroupPeerNumber, + modType: ToxGroupModEvent, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPasswordCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPasswordCallback.kt new file mode 100644 index 000000000..14f09e18a --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPasswordCallback.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPassword + +/** This event is triggered when the group founder changes the group password. */ +interface GroupPasswordCallback { + /** + * @param groupNumber The group number of the group for which the password has changed. + * @param password The new group password. + */ + fun groupPassword( + groupNumber: ToxGroupNumber, + password: ToxGroupPassword, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerExitCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerExitCallback.kt new file mode 100644 index 000000000..7ee14674f --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerExitCallback.kt @@ -0,0 +1,26 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPartMessage +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.enums.ToxGroupExitType + +/** This event is triggered when a peer other than self exits the group. */ +interface GroupPeerExitCallback { + /** + * @param groupNumber The group number of the group in which a peer has left. + * @param peerId The ID of the peer who left the group. This ID no longer designates a valid + * peer and cannot be used for API calls. + * @param exitType The type of exit event. One of ToxGroupExitType. + * @param name The nickname of the peer who left the group. + * @param partMessage The parting message data. + */ + fun groupPeerExit( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + exitType: ToxGroupExitType, + name: ByteArray, + partMessage: ToxGroupPartMessage, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerJoinCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerJoinCallback.kt new file mode 100644 index 000000000..a3c9d15bb --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerJoinCallback.kt @@ -0,0 +1,18 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber + +/** This event is triggered when a peer other than self joins the group. */ +interface GroupPeerJoinCallback { + /** + * @param groupNumber The group number of the group in which a new peer has joined. + * @param peerId The permanent ID of the new peer. This id should not be relied on for client + * behaviour and should be treated as a random value. + */ + fun groupPeerJoin( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerLimitCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerLimitCallback.kt new file mode 100644 index 000000000..98a616c5d --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerLimitCallback.kt @@ -0,0 +1,16 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber + +/** This event is triggered when the group founder changes the maximum peer limit. */ +interface GroupPeerLimitCallback { + /** + * @param groupNumber The group number of the group for which the peer limit has changed. + * @param peerLimit The new peer limit for the group. + */ + fun groupPeerLimit( + groupNumber: ToxGroupNumber, + peerLimit: Int, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerNameCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerNameCallback.kt new file mode 100644 index 000000000..87334102a --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerNameCallback.kt @@ -0,0 +1,19 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber + +/** This event is triggered when a peer changes their nickname. */ +interface GroupPeerNameCallback { + /** + * @param groupNumber The group number of the group the name change is intended for. + * @param peerId The ID of the peer who has changed their name. + * @param name The name data. + */ + fun groupPeerName( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + name: ByteArray, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerStatusCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerStatusCallback.kt new file mode 100644 index 000000000..6263049b1 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPeerStatusCallback.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.enums.ToxUserStatus + +/** This event is triggered when a peer changes their status. */ +interface GroupPeerStatusCallback { + /** + * @param groupNumber The group number of the group the status change is intended for. + * @param peerId The ID of the peer who has changed their status. + * @param status The new status of the peer. + */ + fun groupPeerStatus( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + status: ToxUserStatus, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPrivacyStateCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPrivacyStateCallback.kt new file mode 100644 index 000000000..05443a5e6 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPrivacyStateCallback.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.enums.ToxGroupPrivacyState + +/** This event is triggered when the group founder changes the privacy state. */ +interface GroupPrivacyStateCallback { + /** + * @param groupNumber The group number of the group the privacy state is intended for. + * @param privacyState The new privacy state. + */ + fun groupPrivacyState( + groupNumber: ToxGroupNumber, + privacyState: ToxGroupPrivacyState, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPrivateMessageCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPrivateMessageCallback.kt new file mode 100644 index 000000000..ced11a77e --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupPrivateMessageCallback.kt @@ -0,0 +1,26 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupMessageId +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.enums.ToxMessageType + +/** This event is triggered when the client receives a private message. */ +interface GroupPrivateMessageCallback { + /** + * @param groupNumber The group number of the group the private message is intended for. + * @param peerId The ID of the peer who sent the private message. + * @param messageType The type of message (normal, action, ...). + * @param message The message data. + * @param messageId A pseudo message id that clients can use to uniquely identify this group + * message. + */ + fun groupPrivateMessage( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + messageType: ToxMessageType, + message: ByteArray, + messageId: ToxGroupMessageId, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupSelfJoinCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupSelfJoinCallback.kt new file mode 100644 index 000000000..e13bfec8b --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupSelfJoinCallback.kt @@ -0,0 +1,15 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber + +/** + * This event is triggered when the client has successfully joined a group. Use this to initialize + * any group information the client may need. + */ +interface GroupSelfJoinCallback { + /** @param groupNumber The group number of the group that the client has joined. */ + fun groupSelfJoin( + groupNumber: ToxGroupNumber, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupTopicCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupTopicCallback.kt new file mode 100644 index 000000000..a3c98f1fb --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupTopicCallback.kt @@ -0,0 +1,21 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.data.ToxGroupTopic + +/** This event is triggered when a peer changes the group topic. */ +interface GroupTopicCallback { + /** + * @param groupNumber The group number of the group the topic change is intended for. + * @param peerId The ID of the peer who changed the topic. If the peer who set the topic is not + * present in our peer list this value will be set to 0. + * @param topic The topic data. + */ + fun groupTopic( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + topic: ToxGroupTopic, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupTopicLockCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupTopicLockCallback.kt new file mode 100644 index 000000000..08cb96930 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupTopicLockCallback.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.enums.ToxGroupTopicLock + +/** This event is triggered when the group founder changes the topic lock status. */ +interface GroupTopicLockCallback { + /** + * @param groupNumber The group number of the group for which the topic lock has changed. + * @param topicLock The new topic lock state. + */ + fun groupTopicLock( + groupNumber: ToxGroupNumber, + topicLock: ToxGroupTopicLock, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupVoiceStateCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupVoiceStateCallback.kt new file mode 100644 index 000000000..a61f0a894 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/GroupVoiceStateCallback.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.callbacks + +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.enums.ToxGroupVoiceState + +/** This event is triggered when the group founder changes the voice state. */ +interface GroupVoiceStateCallback { + /** + * @param groupNumber The group number of the group the voice state change is intended for. + * @param voiceState The new voice state. + */ + fun groupVoiceState( + groupNumber: ToxGroupNumber, + voiceState: ToxGroupVoiceState, + state: ToxCoreState, + ): ToxCoreState = state +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/SelfConnectionStatusCallback.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/SelfConnectionStatusCallback.kt index 5268afdb6..2eeca04c5 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/SelfConnectionStatusCallback.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/SelfConnectionStatusCallback.kt @@ -4,12 +4,14 @@ import im.tox.tox4j.core.enums.ToxConnection /** * This event is triggered whenever there is a change in the DHT connection state. When - * disconnected, a client may choose to call [[ToxCore.bootstrap]] again, to reconnect to the DHT. - * Note that this state may frequently change for short amounts of time. Clients should therefore - * not immediately bootstrap on receiving a disconnect. + * disconnected, a client may choose to call tox_bootstrap again, to reconnect to the DHT. Note that + * this state may frequently change for short amounts of time. Clients should therefore not + * immediately bootstrap on receiving a disconnect. + * + * TODO(iphydf): how long should a client wait before bootstrapping again? */ interface SelfConnectionStatusCallback { - /** @param connectionStatus The new connection status. */ + /** @param connectionStatus Whether we are connected to the DHT. */ fun selfConnectionStatus( connectionStatus: ToxConnection, state: ToxCoreState, diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ToxCoreEventListener.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ToxCoreEventListener.kt index de748a683..994c349e7 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ToxCoreEventListener.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/callbacks/ToxCoreEventListener.kt @@ -1,18 +1,42 @@ package im.tox.tox4j.core.callbacks interface ToxCoreEventListener : - SelfConnectionStatusCallback, - FileRecvControlCallback, + ConferenceConnectedCallback, + ConferenceInviteCallback, + ConferenceMessageCallback, + ConferencePeerListChangedCallback, + ConferencePeerNameCallback, + ConferenceTitleCallback, + FileChunkRequestCallback, FileRecvCallback, FileRecvChunkCallback, - FileChunkRequestCallback, + FileRecvControlCallback, FriendConnectionStatusCallback, + FriendLosslessPacketCallback, + FriendLossyPacketCallback, FriendMessageCallback, FriendNameCallback, + FriendReadReceiptCallback, FriendRequestCallback, FriendStatusCallback, FriendStatusMessageCallback, FriendTypingCallback, - FriendLosslessPacketCallback, - FriendLossyPacketCallback, - FriendReadReceiptCallback + GroupCustomPacketCallback, + GroupCustomPrivatePacketCallback, + GroupInviteCallback, + GroupJoinFailCallback, + GroupMessageCallback, + GroupModerationCallback, + GroupPasswordCallback, + GroupPeerExitCallback, + GroupPeerJoinCallback, + GroupPeerLimitCallback, + GroupPeerNameCallback, + GroupPeerStatusCallback, + GroupPrivacyStateCallback, + GroupPrivateMessageCallback, + GroupSelfJoinCallback, + GroupTopicCallback, + GroupTopicLockCallback, + GroupVoiceStateCallback, + SelfConnectionStatusCallback diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceId.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceId.kt new file mode 100644 index 000000000..f6175d53b --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceId.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferenceId(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceMessage.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceMessage.kt new file mode 100644 index 000000000..5a4fcbf02 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceMessage.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferenceMessage(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceNumber.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceNumber.kt new file mode 100644 index 000000000..de7889b1e --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceNumber.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferenceNumber(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceOfflinePeerNumber.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceOfflinePeerNumber.kt new file mode 100644 index 000000000..5d9af8ae5 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceOfflinePeerNumber.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferenceOfflinePeerNumber(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferencePeerName.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferencePeerName.kt new file mode 100644 index 000000000..fbca495c7 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferencePeerName.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferencePeerName(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferencePeerNumber.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferencePeerNumber.kt new file mode 100644 index 000000000..2148b1f44 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferencePeerNumber.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferencePeerNumber(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceTitle.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceTitle.kt new file mode 100644 index 000000000..3939599ec --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceTitle.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferenceTitle(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceUid.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceUid.kt new file mode 100644 index 000000000..ef9c5e27a --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxConferenceUid.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxConferenceUid(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxFriendMessageId.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxFriendMessageId.kt new file mode 100644 index 000000000..8c6168e13 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxFriendMessageId.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxFriendMessageId(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupChatId.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupChatId.kt new file mode 100644 index 000000000..83f81a843 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupChatId.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupChatId(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupMessage.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupMessage.kt new file mode 100644 index 000000000..de29a4394 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupMessage.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupMessage(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupMessageId.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupMessageId.kt new file mode 100644 index 000000000..dbe25f048 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupMessageId.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupMessageId(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupName.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupName.kt new file mode 100644 index 000000000..24596bc1b --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupName.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupName(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupNumber.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupNumber.kt new file mode 100644 index 000000000..79d0ed424 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupNumber.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupNumber(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPartMessage.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPartMessage.kt new file mode 100644 index 000000000..f61ede8fa --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPartMessage.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupPartMessage(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPassword.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPassword.kt new file mode 100644 index 000000000..d1770ec11 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPassword.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupPassword(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPeerNumber.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPeerNumber.kt new file mode 100644 index 000000000..b66cff3b4 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupPeerNumber.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupPeerNumber(val value: Int) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupTopic.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupTopic.kt new file mode 100644 index 000000000..f8b301f54 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/data/ToxGroupTopic.kt @@ -0,0 +1,5 @@ +package im.tox.tox4j.core.data + +import kotlin.jvm.JvmInline + +@JvmInline value class ToxGroupTopic(val value: ByteArray) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConferenceType.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConferenceType.kt new file mode 100644 index 000000000..c7d5ad259 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConferenceType.kt @@ -0,0 +1,10 @@ +package im.tox.tox4j.core.enums + +/** Conference types for the conference_invite event. */ +enum class ToxConferenceType { + /** Text-only conferences that must be accepted with the tox_conference_join function. */ + TEXT, + + /** Video conference. The function to accept these is in toxav. */ + AV, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConnection.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConnection.kt index 6ad324cf3..4ba3978da 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConnection.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxConnection.kt @@ -1,27 +1,24 @@ package im.tox.tox4j.core.enums -/** - * Protocols that can be used to connect to the network or friends. - */ +/** Protocols that can be used to connect to the network or friends. */ enum class ToxConnection { /** - * There is no connection. This instance, or the friend the state change is - * about, is now offline. + * There is no connection. This instance, or the friend the state change is about, is now + * offline. */ NONE, /** - * A TCP connection has been established. For the own instance, this means it - * is connected through a TCP relay, only. For a friend, this means that the - * connection to that particular friend goes through a TCP relay. + * A TCP connection has been established. For the own instance, this means it is connected + * through a TCP relay, only. For a friend, this means that the connection to that particular + * friend goes through a TCP relay. */ TCP, /** - * A UDP connection has been established. For the own instance, this means it - * is able to send UDP packets to DHT nodes, but may still be connected to - * a TCP relay. For a friend, this means that the connection to that - * particular friend was built using direct UDP packets. + * A UDP connection has been established. For the own instance, this means it is able to send + * UDP packets to DHT nodes, but may still be connected to a TCP relay. For a friend, this means + * that the connection to that particular friend was built using direct UDP packets. */ UDP, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileControl.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileControl.kt index 42c8bffa5..59968a9df 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileControl.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileControl.kt @@ -2,22 +2,22 @@ package im.tox.tox4j.core.enums enum class ToxFileControl { /** - * Sent by the receiving side to accept a file send request. Also sent after a - * {@link #PAUSE} command to continue sending or receiving. + * Sent by the receiving side to accept a file send request. Also sent after a {@link #PAUSE} + * command to continue sending or receiving. */ RESUME, /** - * Sent by clients to pause the file transfer. The initial state of a file - * transfer is always paused on the receiving side and running on the sending - * side. If both the sending and receiving side pause the transfer, then both - * need to send {@link #RESUME} for the transfer to resume. + * Sent by clients to pause the file transfer. The initial state of a file transfer is always + * paused on the receiving side and running on the sending side. If both the sending and + * receiving side pause the transfer, then both need to send {@link #RESUME} for the transfer to + * resume. */ PAUSE, /** - * Sent by the receiving side to reject a file send request before any other - * commands are sent. Also sent by either side to terminate a file transfer. + * Sent by the receiving side to reject a file send request before any other commands are sent. + * Also sent by either side to terminate a file transfer. */ CANCEL, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileKind.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileKind.kt index d59fc8a74..1b676df34 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileKind.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxFileKind.kt @@ -2,8 +2,8 @@ package im.tox.tox4j.core.enums object ToxFileKind { /** - * Arbitrary file data. Clients can choose to handle it based on the file name - * or magic or any other way they choose. + * Arbitrary file data. Clients can choose to handle it based on the file name or magic or any + * other way they choose. */ const val DATA = 0 @@ -11,24 +11,21 @@ object ToxFileKind { * Avatar image data. * *

- * Avatars can be sent at any time the client wishes. Generally, a client will - * send the avatar to a friend when that friend comes online, and to all - * friends when the avatar changed. A client can save some traffic by - * remembering which friend received the updated avatar already and only send - * it if the friend has an out of date avatar. + * Avatars can be sent at any time the client wishes. Generally, a client will send the avatar + * to a friend when that friend comes online, and to all friends when the avatar changed. A + * client can save some traffic by remembering which friend received the updated avatar already + * and only send it if the friend has an out of date avatar. * *

- * Clients who receive avatar send requests can reject it (by sending - * {@link FileControl#CANCEL} before any other controls), or accept it - * (by sending {@link FileControl#RESUME}). - * The file_id of length {@link ToxCryptoConstants#HASH_LENGTH} bytes (same - * length as {@link ToxCoreConstants#FILE_ID_LENGTH}) will contain the hash. - * A client can compare this hash with a saved hash and send - * {@link FileControl#CANCEL} to terminate the avatar transfer if it matches. + * Clients who receive avatar send requests can reject it (by sending {@link FileControl#CANCEL} + * before any other controls), or accept it (by sending {@link FileControl#RESUME}). The file_id + * of length {@link ToxCryptoConstants#HASH_LENGTH} bytes (same length as {@link + * ToxCoreConstants#FILE_ID_LENGTH}) will contain the hash. A client can compare this hash with + * a saved hash and send {@link FileControl#CANCEL} to terminate the avatar transfer if it + * matches. * *

- * When fileSize is set to 0 in the transfer request it means that the client - * has no avatar. + * When fileSize is set to 0 in the transfer request it means that the client has no avatar. */ const val AVATAR = 1 } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupExitType.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupExitType.kt new file mode 100644 index 000000000..7fb1fa1de --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupExitType.kt @@ -0,0 +1,25 @@ +package im.tox.tox4j.core.enums + +/** Represents peer exit events. These should be used with the `group_peer_exit` event. */ +enum class ToxGroupExitType { + /** The peer has quit the group. */ + QUIT, + + /** Your connection with this peer has timed out. */ + TIMEOUT, + + /** Your connection with this peer has been severed. */ + DISCONNECTED, + + /** + * Your connection with all peers has been severed. This will occur when you are kicked from a + * group, rejoin a group, or manually disconnect from a group. + */ + SELF_DISCONNECTED, + + /** The peer has been kicked. */ + KICK, + + /** The peer provided invalid group sync information. */ + SYNC_ERROR, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupJoinFail.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupJoinFail.kt new file mode 100644 index 000000000..e22665362 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupJoinFail.kt @@ -0,0 +1,19 @@ +package im.tox.tox4j.core.enums + +/** + * Represents types of failed group join attempts. These are used in the tox_callback_group_rejected + * callback when a peer fails to join a group. + */ +enum class ToxGroupJoinFail { + /** The group peer limit has been reached. */ + PEER_LIMIT, + + /** You have supplied an invalid password. */ + INVALID_PASSWORD, + + /** + * The join attempt failed due to an unspecified error. This often occurs when the group is not + * found in the DHT. + */ + UNKNOWN, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupModEvent.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupModEvent.kt new file mode 100644 index 000000000..f3cad2e68 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupModEvent.kt @@ -0,0 +1,16 @@ +package im.tox.tox4j.core.enums + +/** Represents moderation events. These should be used with the `group_moderation` event. */ +enum class ToxGroupModEvent { + /** A peer has been kicked from the group. */ + KICK, + + /** A peer as been given the observer role. */ + OBSERVER, + + /** A peer has been given the user role. */ + USER, + + /** A peer has been given the moderator role. */ + MODERATOR, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupPrivacyState.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupPrivacyState.kt new file mode 100644 index 000000000..140b410cf --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupPrivacyState.kt @@ -0,0 +1,23 @@ +package im.tox.tox4j.core.enums + +/** Represents the group privacy state. */ +enum class ToxGroupPrivacyState { + /** + * The group is considered to be public. Anyone may join the group using the Chat ID. + * + * If the group is in this state, even if the Chat ID is never explicitly shared with someone + * outside of the group, information including the Chat ID, IP addresses, and peer ID's (but not + * Tox ID's) is visible to anyone with access to a node storing a DHT entry for the given group. + */ + PUBLIC, + + /** + * The group is considered to be private. The only way to join the group is by having someone in + * your contact list send you an invite. + * + * If the group is in this state, no group information (mentioned above) is present in the DHT; + * the DHT is not used for any purpose at all. If a public group is set to private, all DHT + * information related to the group will expire shortly. + */ + PRIVATE, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupRole.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupRole.kt new file mode 100644 index 000000000..162a0225e --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupRole.kt @@ -0,0 +1,30 @@ +package im.tox.tox4j.core.enums + +/** + * Represents group roles. + * + * Roles are hierarchical in that each role has a set of privileges plus all the privileges of the + * roles below it. + */ +enum class ToxGroupRole { + /** + * May kick all other peers as well as set their role to anything (except founder). Founders may + * also set the group password, toggle the privacy state, and set the peer limit. + */ + FOUNDER, + + /** + * May kick and set the user and observer roles for peers below this role. May also set the + * group topic. + */ + MODERATOR, + + /** May communicate with other peers normally. */ + USER, + + /** + * May observe the group and ignore peers; may not communicate with other peers or with the + * group. + */ + OBSERVER, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupTopicLock.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupTopicLock.kt new file mode 100644 index 000000000..ca6b4925a --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupTopicLock.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.enums + +/** Represents the state of the group topic lock. */ +enum class ToxGroupTopicLock { + /** + * The topic lock is enabled. Only peers with the founder and moderator roles may set the topic. + */ + ENABLED, + + /** + * The topic lock is disabled. All peers except those with the observer role may set the topic. + */ + DISABLED, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupVoiceState.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupVoiceState.kt new file mode 100644 index 000000000..2040ad9ae --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxGroupVoiceState.kt @@ -0,0 +1,16 @@ +package im.tox.tox4j.core.enums + +/** + * Represents the group voice state, which determines which Group Roles have permission to speak in + * the group chat. The voice state does not have any effect private messages or topic setting. + */ +enum class ToxGroupVoiceState { + /** All group roles above Observer have permission to speak. */ + ALL, + + /** Moderators and Founders have permission to speak. */ + MODERATOR, + + /** Only the founder may speak. */ + FOUNDER, +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxMessageType.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxMessageType.kt index ab0c0876e..4fe4ad345 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxMessageType.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxMessageType.kt @@ -1,18 +1,13 @@ package im.tox.tox4j.core.enums /** - * Represents message types for {@link - * im.tox.tox4j.core.ToxCore#friendSendMessage} and group chat messages. + * Represents message types for {@link im.tox.tox4j.core.ToxCore#friendSendMessage} and group chat + * messages. */ enum class ToxMessageType { - /** - * Normal text message. Similar to PRIVMSG on IRC. - */ + /** Normal text message. Similar to PRIVMSG on IRC. */ NORMAL, - /** - * A message describing an user action. This is similar to /me (CTCP ACTION) - * on IRC. - */ + /** A message describing an user action. This is similar to /me (CTCP ACTION) on IRC. */ ACTION, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxProxyType.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxProxyType.kt index 36aa176ab..19f684df4 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxProxyType.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxProxyType.kt @@ -1,21 +1,13 @@ package im.tox.tox4j.core.enums -/** - * Type of proxy used to connect to TCP relays. - */ +/** Type of proxy used to connect to TCP relays. */ enum class ToxProxyType { - /** - * Don't use a proxy. - */ + /** Don't use a proxy. */ NONE, - /** - * HTTP proxy using CONNECT. - */ + /** HTTP proxy using CONNECT. */ HTTP, - /** - * SOCKS proxy for simple socket pipes. - */ + /** SOCKS proxy for simple socket pipes. */ SOCKS5, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxSavedataType.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxSavedataType.kt index 11d437ef2..a42b24d48 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxSavedataType.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxSavedataType.kt @@ -1,22 +1,13 @@ package im.tox.tox4j.core.enums -/** - * Type of savedata to create the Tox instance from. - */ +/** Type of savedata to create the Tox instance from. */ enum class ToxSavedataType { - /** - * No savedata. - */ + /** No savedata. */ NONE, - /** - * Savedata is one that was obtained from {@link - * im.tox.tox4j.core.ToxCore#getSavedata}. - */ + /** Savedata is one that was obtained from {@link im.tox.tox4j.core.ToxCore#getSavedata}. */ TOX_SAVE, - /** - * Savedata is a secret key of length {@link ToxCoreConstants#SecretKeySize}. - */ + /** Savedata is a secret key of length {@link ToxCoreConstants#SecretKeySize}. */ SECRET_KEY, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxUserStatus.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxUserStatus.kt index 516b35524..462e045bd 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxUserStatus.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/enums/ToxUserStatus.kt @@ -1,23 +1,16 @@ package im.tox.tox4j.core.enums -/** - * Represents the possible statuses a client can have. - */ +/** Represents the possible statuses a client can have. */ enum class ToxUserStatus { - /** - * User is online and available. - */ + /** User is online and available. */ NONE, - /** - * User is away. Clients can set this e.g. after a user defined - * inactivity time. - */ + /** User is away. Clients can set this e.g. after a user defined inactivity time. */ AWAY, /** - * User is busy. Signals to other clients that this client does not - * currently wish to communicate. + * User is busy. Signals to other clients that this client does not currently wish to + * communicate. */ BUSY, } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/Makefile b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/Makefile deleted file mode 100644 index cbc0eac30..000000000 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -all: ../../mkexceptions exceptions.json - $+ diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxBootstrapException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxBootstrapException.kt index 4d72b4e68..2fcb4e32f 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxBootstrapException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxBootstrapException.kt @@ -5,28 +5,24 @@ import im.tox.tox4j.exceptions.ToxException class ToxBootstrapException : ToxException { enum class Code { - /** - * The public key was of invalid length. - */ - @JavaOnly BAD_KEY, + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, /** - * The address could not be resolved to an IP address, or the IP address - * passed was invalid. + * The hostname could not be resolved to an IP address, the IP address passed was invalid, + * or the function failed to send the initial request packet to the bootstrap node or TCP + * relay. */ BAD_HOST, - /** - * The port passed was invalid. The valid port range is (1, 65535). - */ + /** The port passed was invalid. The valid port range is (1, 65535). */ BAD_PORT, - /** - * An argument was null. - */ - NULL, + /** The public key was of invalid length. */ + @JavaOnly BAD_KEY, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceByIdException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceByIdException.kt new file mode 100644 index 000000000..472951548 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceByIdException.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceByIdException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + + /** The invite packet failed to send. */ + FAIL_SEND, + + /** The client is not connected to the conference. */ + NO_CONNECTION, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceByUidException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceByUidException.kt new file mode 100644 index 000000000..9e3e612e4 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceByUidException.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceByUidException : ToxException { + enum class Code { + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, + + /** No conference with the given uid exists on the conference list. */ + NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceDeleteException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceDeleteException.kt new file mode 100644 index 000000000..21a315c16 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceDeleteException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceDeleteException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceGetTypeException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceGetTypeException.kt new file mode 100644 index 000000000..3059937f2 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceGetTypeException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceGetTypeException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceInviteException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceInviteException.kt new file mode 100644 index 000000000..e00d6ad3a --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceInviteException.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceInviteException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + + /** The invite packet failed to send. */ + FAIL_SEND, + + /** The client is not connected to the conference. */ + NO_CONNECTION, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceJoinException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceJoinException.kt new file mode 100644 index 000000000..6bfa95461 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceJoinException.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceJoinException : ToxException { + enum class Code { + /** The cookie passed has an invalid length. */ + INVALID_LENGTH, + + /** The conference is not the expected type. This indicates an invalid cookie. */ + WRONG_TYPE, + + /** The friend number passed does not designate a valid friend. */ + FRIEND_NOT_FOUND, + + /** Client is already in this conference. */ + DUPLICATE, + + /** Conference instance failed to initialize. */ + INIT_FAIL, + + /** The join packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceNewException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceNewException.kt new file mode 100644 index 000000000..5c544ab0e --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceNewException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceNewException : ToxException { + enum class Code { + /** The conference instance failed to initialize. */ + INIT, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferencePeerQueryException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferencePeerQueryException.kt new file mode 100644 index 000000000..b4ddc7d2c --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferencePeerQueryException.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferencePeerQueryException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + + /** The peer number passed did not designate a valid peer. */ + PEER_NOT_FOUND, + + /** The client is not connected to the conference. */ + NO_CONNECTION, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceSendMessageException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceSendMessageException.kt new file mode 100644 index 000000000..2df26ddd7 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceSendMessageException.kt @@ -0,0 +1,23 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceSendMessageException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + + /** The message is too long. */ + TOO_LONG, + + /** The client is not connected to the conference. */ + NO_CONNECTION, + + /** The message packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceSetMaxOfflineException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceSetMaxOfflineException.kt new file mode 100644 index 000000000..83d28d0e7 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceSetMaxOfflineException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceSetMaxOfflineException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceTitleException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceTitleException.kt new file mode 100644 index 000000000..9e4ceb0d9 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxConferenceTitleException.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxConferenceTitleException : ToxException { + enum class Code { + /** The conference number passed did not designate a valid conference. */ + CONFERENCE_NOT_FOUND, + + /** The title is too long or empty. */ + INVALID_LENGTH, + + /** The title packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileControlException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileControlException.kt index 957dccc04..12e012a12 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileControlException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileControlException.kt @@ -4,43 +4,32 @@ import im.tox.tox4j.exceptions.ToxException class ToxFileControlException : ToxException { enum class Code { - /** - * A {@link ToxFileControl#PAUSE} control was sent, but the file transfer was already paused. - */ - ALREADY_PAUSED, - - /** - * A {@link ToxFileControl#RESUME} control was sent, but the file transfer was paused by the other - * party. Only the party that paused the transfer can resume it. - */ - DENIED, + /** The friendNumber passed did not designate a valid friend. */ + FRIEND_NOT_FOUND, - /** - * This client is currently not connected to the friend. - */ + /** This client is currently not connected to the friend. */ FRIEND_NOT_CONNECTED, - /** - * The friendNumber passed did not designate a valid friend. - */ - FRIEND_NOT_FOUND, - - /** - * No file transfer with the given file number was found for the given friend. - */ + /** No file transfer with the given file number was found for the given friend. */ NOT_FOUND, - /** - * A {@link ToxFileControl#RESUME} control was sent, but the file transfer is running normally. - */ + /** A RESUME control was sent, but the file transfer is running normally. */ NOT_PAUSED, /** - * An allocation error occurred while increasing the send queue size. + * A RESUME control was sent, but the file transfer was paused by the other party. Only the + * party that paused the transfer can resume it. */ + DENIED, + + /** A PAUSE control was sent, but the file transfer was already paused. */ + ALREADY_PAUSED, + + /** Packet queue is full. */ SENDQ, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileGetException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileGetException.kt index 05375cdb6..0e29f72b7 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileGetException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileGetException.kt @@ -4,22 +4,17 @@ import im.tox.tox4j.exceptions.ToxException class ToxFileGetException : ToxException { enum class Code { - /** - * The friendNumber passed did not designate a valid friend. - */ + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, + + /** The friendNumber passed did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * No file transfer with the given file number was found for the given friend. - */ + /** No file transfer with the given file number was found for the given friend. */ NOT_FOUND, - - /** - * An argument was null. - */ - NULL, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSeekException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSeekException.kt index ca89461f6..34757b0e5 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSeekException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSeekException.kt @@ -4,37 +4,26 @@ import im.tox.tox4j.exceptions.ToxException class ToxFileSeekException : ToxException { enum class Code { - /** - * File was not in a state where it could be seeked. - */ - DENIED, + /** The friendNumber passed did not designate a valid friend. */ + FRIEND_NOT_FOUND, - /** - * This client is currently not connected to the friend. - */ + /** This client is currently not connected to the friend. */ FRIEND_NOT_CONNECTED, - /** - * The friendNumber passed did not designate a valid friend. - */ - FRIEND_NOT_FOUND, + /** No file transfer with the given file number was found for the given friend. */ + NOT_FOUND, - /** - * Seek position was invalid. - */ - INVALID_POSITION, + /** File was not in a state where it could be seeked. */ + DENIED, - /** - * No file transfer with the given file number was found for the given friend. - */ - NOT_FOUND, + /** Seek position was invalid */ + INVALID_POSITION, - /** - * An allocation error occurred while increasing the send queue size. - */ + /** Packet queue is full. */ SENDQ, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendChunkException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendChunkException.kt index fa263687e..26a4958e8 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendChunkException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendChunkException.kt @@ -4,50 +4,39 @@ import im.tox.tox4j.exceptions.ToxException class ToxFileSendChunkException : ToxException { enum class Code { - /** - * This client is currently not connected to the friend. - */ - FRIEND_NOT_CONNECTED, + /** The length parameter was non-zero, but data was NULL. */ + NULL, - /** - * The friendNumber passed did not designate a valid friend. - */ + /** The friendNumber passed did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * Attempted to send more or less data than requested. The requested data size is - * adjusted according to maximum transmission unit and the expected end of - * the file. Trying to send less or more than requested will return this error. - */ - INVALID_LENGTH, + /** This client is currently not connected to the friend. */ + FRIEND_NOT_CONNECTED, - /** - * No file transfer with the given file number was found for the given friend. - */ + /** No file transfer with the given file number was found for the given friend. */ NOT_FOUND, /** - * File transfer was found but isn't in a transferring state: (paused, done, - * broken, etc...) (happens only when not called from the request chunk callback). + * File transfer was found but isn't in a transferring state: (paused, done, broken, etc...) + * (happens only when not called from the request chunk callback). */ NOT_TRANSFERRING, /** - * An argument was null. + * Attempted to send more or less data than requested. The requested data size is adjusted + * according to maximum transmission unit and the expected end of the file. Trying to send + * less or more than requested will return this error. */ - NULL, + INVALID_LENGTH, - /** - * An allocation error occurred while increasing the send queue size. - */ + /** Packet queue is full. */ SENDQ, - /** - * Position parameter was wrong. - */ + /** Position parameter was wrong. */ WRONG_POSITION, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendException.kt index 3578a7376..7d63083a8 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFileSendException.kt @@ -4,33 +4,26 @@ import im.tox.tox4j.exceptions.ToxException class ToxFileSendException : ToxException { enum class Code { - /** - * This client is currently not connected to the friend. - */ - FRIEND_NOT_CONNECTED, + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, - /** - * The friendNumber passed did not designate a valid friend. - */ + /** The friendNumber passed did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * Filename length exceeded {@link ToxCoreConstants#MAX_FILENAME_LENGTH} bytes. - */ - NAME_TOO_LONG, + /** This client is currently not connected to the friend. */ + FRIEND_NOT_CONNECTED, - /** - * An argument was null. - */ - NULL, + /** Filename length exceeded TOX_MAX_FILENAME_LENGTH bytes. */ + NAME_TOO_LONG, /** - * Too many ongoing transfers. The maximum number of concurrent file transfers - * is 256 per friend per direction (sending and receiving, so 512 total). + * Too many ongoing transfers. The maximum number of concurrent file transfers is 256 per + * friend per direction (sending and receiving). */ TOO_MANY, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendAddException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendAddException.kt index eeb9f7749..7d29a2186 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendAddException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendAddException.kt @@ -4,50 +4,38 @@ import im.tox.tox4j.exceptions.ToxException class ToxFriendAddException : ToxException { enum class Code { - /** - * A friend request has already been sent, or the address belongs to a friend - * that is already on the friend list. To resend a friend request, first remove - * the friend, and then call addFriend again. - */ - ALREADY_SENT, - - /** - * The friend address checksum failed. - */ - BAD_CHECKSUM, + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, - /** - * A memory allocation failed when trying to increase the friend list size. - */ - MALLOC, + /** The length of the friend request message exceeded TOX_MAX_FRIEND_REQUEST_LENGTH. */ + TOO_LONG, /** - * The friend request message was empty. This, and the TOO_LONG code will - * never be returned from {@link ToxCore#addFriendNoRequest}. + * The friend request message was empty. This, and the TOO_LONG code will never be returned + * from tox_friend_add_norequest. */ NO_MESSAGE, - /** - * An argument was null. - */ - NULL, - - /** - * The friend address belongs to the sending client. - */ + /** The friend address belongs to the sending client. */ OWN_KEY, /** - * The friend was already on the friend list, but the noSpam value was different. + * A friend request has already been sent, or the address belongs to a friend that is + * already on the friend list. */ + ALREADY_SENT, + + /** The friend address checksum failed. */ + BAD_CHECKSUM, + + /** The friend was already there, but the nospam value was different. */ SET_NEW_NOSPAM, - /** - * The length of the friend request message exceeded {@link ToxCoreConstants#MAX_FRIEND_REQUEST_LENGTH}. - */ - TOO_LONG, + /** A memory allocation failed when trying to increase the friend list size. */ + MALLOC, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendByPublicKeyException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendByPublicKeyException.kt index bfc6a175b..5a35c499c 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendByPublicKeyException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendByPublicKeyException.kt @@ -4,17 +4,14 @@ import im.tox.tox4j.exceptions.ToxException class ToxFriendByPublicKeyException : ToxException { enum class Code { - /** - * No friend with the given Public Key exists on the friend list. - */ - NOT_FOUND, - - /** - * An argument was null. - */ + /** One of the arguments to the function was NULL when it was not expected. */ NULL, + + /** No friend with the given Public Key exists on the friend list. */ + NOT_FOUND, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendCustomPacketException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendCustomPacketException.kt index 5e03db432..77772a0d0 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendCustomPacketException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendCustomPacketException.kt @@ -4,43 +4,32 @@ import im.tox.tox4j.exceptions.ToxException class ToxFriendCustomPacketException : ToxException { enum class Code { - /** - * Attempted to send an empty packet. - */ - EMPTY, - - /** - * This client is currently not connected to the friend. - */ - FRIEND_NOT_CONNECTED, + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, - /** - * The friendNumber passed did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * The first byte of data was not in the specified range for the packet type. - * This range is 200-254 for lossy, and 160-191 for lossless packets. - */ - INVALID, + /** This client is currently not connected to the friend. */ + FRIEND_NOT_CONNECTED, /** - * An argument was null. + * The first byte of data was not in the specified range for the packet type. This range is + * 192-254 for lossy, and 69, 160-191 for lossless packets. */ - NULL, + INVALID, - /** - * An allocation error occurred while increasing the send queue size. - */ - SENDQ, + /** Attempted to send an empty packet. */ + EMPTY, - /** - * Packet data length exceeded {@link ToxCoreConstants#MAX_CUSTOM_PACKET_SIZE}. - */ + /** Packet data length exceeded TOX_MAX_CUSTOM_PACKET_SIZE. */ TOO_LONG, + + /** Packet queue is full. */ + SENDQ, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendDeleteException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendDeleteException.kt index 1c159c199..ee8659d11 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendDeleteException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendDeleteException.kt @@ -4,12 +4,11 @@ import im.tox.tox4j.exceptions.ToxException class ToxFriendDeleteException : ToxException { enum class Code { - /** - * There was no friend with the given friend number. No friends were deleted. - */ + /** There was no friend with the given friend number. No friends were deleted. */ FRIEND_NOT_FOUND, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendGetPublicKeyException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendGetPublicKeyException.kt index aa1bb6694..31cab6840 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendGetPublicKeyException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendGetPublicKeyException.kt @@ -4,12 +4,11 @@ import im.tox.tox4j.exceptions.ToxException class ToxFriendGetPublicKeyException : ToxException { enum class Code { - /** - * The friendNumber passed did not designate a valid friend. - */ + /** No friend with the given number exists on the friend list. */ FRIEND_NOT_FOUND, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendSendMessageException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendSendMessageException.kt index 557fd1e8b..9dd1f1472 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendSendMessageException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxFriendSendMessageException.kt @@ -4,37 +4,26 @@ import im.tox.tox4j.exceptions.ToxException class ToxFriendSendMessageException : ToxException { enum class Code { - /** - * Attempted to send a zero-length message. - */ - EMPTY, - - /** - * This client is currently not connected to the friend. - */ - FRIEND_NOT_CONNECTED, + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, - /** - * The friend number did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, - /** - * An argument was null. - */ - NULL, + /** This client is currently not connected to the friend. */ + FRIEND_NOT_CONNECTED, - /** - * An allocation error occurred while increasing the send queue size. - */ + /** An allocation error occurred while increasing the send queue size. */ SENDQ, - /** - * Message length exceeded {@link ToxCoreConstants#MAX_MESSAGE_LENGTH}. - */ + /** Message length exceeded TOX_MAX_MESSAGE_LENGTH. */ TOO_LONG, + + /** Attempted to send a zero-length message. */ + EMPTY, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGetPortException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGetPortException.kt index 8627a9407..14e836f51 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGetPortException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGetPortException.kt @@ -4,12 +4,11 @@ import im.tox.tox4j.exceptions.ToxException class ToxGetPortException : ToxException { enum class Code { - /** - * The instance was not bound to any port. - */ + /** The instance was not bound to any port. */ NOT_BOUND, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupDisconnectException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupDisconnectException.kt new file mode 100644 index 000000000..a0c0c6ccb --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupDisconnectException.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupDisconnectException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The group is already disconnected. */ + ALREADY_DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupInviteAcceptException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupInviteAcceptException.kt new file mode 100644 index 000000000..3db8c4f66 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupInviteAcceptException.kt @@ -0,0 +1,35 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupInviteAcceptException : ToxException { + enum class Code { + /** The invite data is not in the expected format. */ + BAD_INVITE, + + /** The group instance failed to initialize. */ + INIT_FAILED, + + /** name exceeds TOX_MAX_NAME_LENGTH */ + TOO_LONG, + + /** name is NULL or name_length is zero. */ + EMPTY, + + /** + * Failed to set password. This usually occurs if the password exceeds + * TOX_GROUP_MAX_PASSWORD_SIZE. + */ + PASSWORD, + + /** The friend number passed did not designate a valid friend. */ + FRIEND_NOT_FOUND, + + /** Packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupInviteFriendException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupInviteFriendException.kt new file mode 100644 index 000000000..4d8795635 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupInviteFriendException.kt @@ -0,0 +1,26 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupInviteFriendException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The friend number passed did not designate a valid friend. */ + FRIEND_NOT_FOUND, + + /** Creation of the invite packet failed. This indicates a network related error. */ + INVITE_FAIL, + + /** Packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupIsConnectedException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupIsConnectedException.kt new file mode 100644 index 000000000..d59cc5ca3 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupIsConnectedException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupIsConnectedException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupJoinException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupJoinException.kt new file mode 100644 index 000000000..66545a74c --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupJoinException.kt @@ -0,0 +1,35 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupJoinException : ToxException { + enum class Code { + /** The group instance failed to initialize. */ + INIT, + + /** + * The chat_id pointer is set to NULL or a group with chat_id already exists. This usually + * happens if the client attempts to create multiple sessions for the same group. + */ + BAD_CHAT_ID, + + /** name is NULL or name_length is zero. */ + EMPTY, + + /** name exceeds TOX_MAX_NAME_LENGTH. */ + TOO_LONG, + + /** + * Failed to set password. This usually occurs if the password exceeds + * TOX_GROUP_MAX_PASSWORD_SIZE. + */ + PASSWORD, + + /** There was a core error when initiating the group. */ + CORE, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupKickPeerException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupKickPeerException.kt new file mode 100644 index 000000000..9d30b0a37 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupKickPeerException.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupKickPeerException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The ID passed did not designate a valid peer. */ + PEER_NOT_FOUND, + + /** The caller does not have the required permissions for this action. */ + PERMISSIONS, + + /** The peer could not be kicked from the group. */ + FAIL_ACTION, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The caller attempted to set their own role. */ + SELF, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupLeaveException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupLeaveException.kt new file mode 100644 index 000000000..8bc7af408 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupLeaveException.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupLeaveException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** Message length exceeded TOX_GROUP_MAX_PART_LENGTH. */ + TOO_LONG, + + /** The parting packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupNewException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupNewException.kt new file mode 100644 index 000000000..7dd2e3f61 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupNewException.kt @@ -0,0 +1,31 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupNewException : ToxException { + enum class Code { + /** + * name exceeds TOX_MAX_NAME_LENGTH or group_name exceeded TOX_GROUP_MAX_GROUP_NAME_LENGTH. + */ + TOO_LONG, + + /** name or group_name is NULL or length is zero. */ + EMPTY, + + /** The group instance failed to initialize. */ + INIT, + + /** + * The group state failed to initialize. This usually indicates that something went wrong + * related to cryptographic signing. + */ + STATE, + + /** The group failed to announce to the DHT. This indicates a network related error. */ + ANNOUNCE, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupPeerQueryException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupPeerQueryException.kt new file mode 100644 index 000000000..480b48e69 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupPeerQueryException.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupPeerQueryException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The ID passed did not designate a valid peer. */ + PEER_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupReconnectException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupReconnectException.kt new file mode 100644 index 000000000..ba4014b56 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupReconnectException.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupReconnectException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** There was a core error when initiating the group. */ + CORE, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfNameSetException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfNameSetException.kt new file mode 100644 index 000000000..b13ccc4cf --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfNameSetException.kt @@ -0,0 +1,23 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSelfNameSetException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** Name length exceeded TOX_MAX_NAME_LENGTH. */ + TOO_LONG, + + /** The length given to the set function is zero or name is a NULL pointer. */ + INVALID, + + /** The packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfQueryException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfQueryException.kt new file mode 100644 index 000000000..37ab3d837 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfQueryException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSelfQueryException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfStatusSetException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfStatusSetException.kt new file mode 100644 index 000000000..d804903ce --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSelfStatusSetException.kt @@ -0,0 +1,17 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSelfStatusSetException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The packet failed to send. */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendCustomPacketException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendCustomPacketException.kt new file mode 100644 index 000000000..3a48dacae --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendCustomPacketException.kt @@ -0,0 +1,32 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSendCustomPacketException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** + * Message length exceeded TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH if the packet was lossy, + * or TOX_GROUP_MAX_CUSTOM_LOSSLESS_PACKET_LENGTH if the packet was lossless. + */ + TOO_LONG, + + /** The message pointer is NULL or length is zero. */ + EMPTY, + + /** The group is disconnected. */ + DISCONNECTED, + + /** + * The packet did not successfully send to any peer. This often indicates a connection issue + * on the sender's side. + */ + FAIL_SEND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendCustomPrivatePacketException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendCustomPrivatePacketException.kt new file mode 100644 index 000000000..d33090fa8 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendCustomPrivatePacketException.kt @@ -0,0 +1,32 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSendCustomPrivatePacketException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** + * Message length exceeded TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH if the packet was lossy, + * or TOX_GROUP_MAX_CUSTOM_LOSSLESS_PACKET_LENGTH if the packet was lossless. + */ + TOO_LONG, + + /** The message pointer is NULL or length is zero. */ + EMPTY, + + /** The peer ID passed did no designate a valid peer. */ + PEER_NOT_FOUND, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendMessageException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendMessageException.kt new file mode 100644 index 000000000..697a8d0db --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendMessageException.kt @@ -0,0 +1,32 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSendMessageException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** Message length exceeded TOX_GROUP_MAX_MESSAGE_LENGTH. */ + TOO_LONG, + + /** The message pointer is NULL or length is zero. */ + EMPTY, + + /** The message type is invalid. */ + BAD_TYPE, + + /** The caller does not have the required permissions to send group messages. */ + PERMISSIONS, + + /** Packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendPrivateMessageException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendPrivateMessageException.kt new file mode 100644 index 000000000..409f2c7ac --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSendPrivateMessageException.kt @@ -0,0 +1,35 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSendPrivateMessageException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The peer ID passed did not designate a valid peer. */ + PEER_NOT_FOUND, + + /** Message length exceeded TOX_GROUP_MAX_MESSAGE_LENGTH. */ + TOO_LONG, + + /** The message pointer is NULL or length is zero. */ + EMPTY, + + /** The message type is invalid. */ + BAD_TYPE, + + /** The caller does not have the required permissions to send group messages. */ + PERMISSIONS, + + /** Packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetIgnoreException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetIgnoreException.kt new file mode 100644 index 000000000..079cec4f8 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetIgnoreException.kt @@ -0,0 +1,20 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetIgnoreException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The ID passed did not designate a valid peer. */ + PEER_NOT_FOUND, + + /** The caller attempted to ignore himself. */ + SELF, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPasswordException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPasswordException.kt new file mode 100644 index 000000000..8a2d094f0 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPasswordException.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetPasswordException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The caller does not have the required permissions to set the password. */ + PERMISSIONS, + + /** Password length exceeded TOX_GROUP_MAX_PASSWORD_SIZE. */ + TOO_LONG, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The function failed to allocate enough memory for the operation. */ + MALLOC, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPeerLimitException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPeerLimitException.kt new file mode 100644 index 000000000..302007a03 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPeerLimitException.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetPeerLimitException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The caller does not have the required permissions to set the peer limit. */ + PERMISSIONS, + + /** + * The peer limit could not be set. This may occur due to an error related to cryptographic + * signing of the new shared state. + */ + FAIL_SET, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPrivacyStateException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPrivacyStateException.kt new file mode 100644 index 000000000..edd3e959c --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetPrivacyStateException.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetPrivacyStateException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The caller does not have the required permissions to set the privacy state. */ + PERMISSIONS, + + /** + * The privacy state could not be set. This may occur due to an error related to + * cryptographic signing of the new shared state. + */ + FAIL_SET, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetRoleException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetRoleException.kt new file mode 100644 index 000000000..95965cf5b --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetRoleException.kt @@ -0,0 +1,35 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetRoleException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The ID passed did not designate a valid peer. Note: you cannot set your own role. */ + PEER_NOT_FOUND, + + /** The caller does not have the required permissions for this action. */ + PERMISSIONS, + + /** + * The role assignment is invalid. This will occur if you try to set a peer's role to the + * role they already have. + */ + ASSIGNMENT, + + /** + * The role was not successfully set. This may occur if the packet failed to send, or if the + * role limit has been reached. + */ + FAIL_ACTION, + + /** The caller attempted to set their own role. */ + SELF, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetTopicLockException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetTopicLockException.kt new file mode 100644 index 000000000..e76902ccc --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetTopicLockException.kt @@ -0,0 +1,32 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetTopicLockException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** Tox_Group_Topic_Lock is an invalid type. */ + INVALID, + + /** The caller does not have the required permissions to set the topic lock. */ + PERMISSIONS, + + /** + * The topic lock could not be set. This may occur due to an error related to cryptographic + * signing of the new shared state. + */ + FAIL_SET, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetVoiceStateException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetVoiceStateException.kt new file mode 100644 index 000000000..b19c983b4 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupSetVoiceStateException.kt @@ -0,0 +1,29 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupSetVoiceStateException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** The caller does not have the required permissions to set the privacy state. */ + PERMISSIONS, + + /** + * The voice state could not be set. This may occur due to an error related to cryptographic + * signing of the new shared state. + */ + FAIL_SET, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupStateQueryException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupStateQueryException.kt new file mode 100644 index 000000000..d579b24a7 --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupStateQueryException.kt @@ -0,0 +1,14 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupStateQueryException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupTopicSetException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupTopicSetException.kt new file mode 100644 index 000000000..f678c53cb --- /dev/null +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxGroupTopicSetException.kt @@ -0,0 +1,31 @@ +package im.tox.tox4j.core.exceptions + +import im.tox.tox4j.exceptions.ToxException + +class ToxGroupTopicSetException : ToxException { + enum class Code { + /** The group number passed did not designate a valid group. */ + GROUP_NOT_FOUND, + + /** Topic length exceeded TOX_GROUP_MAX_TOPIC_LENGTH. */ + TOO_LONG, + + /** The caller does not have the required permissions to set the topic. */ + PERMISSIONS, + + /** + * The packet could not be created. This error is usually related to cryptographic signing. + */ + FAIL_CREATE, + + /** The packet failed to send. */ + FAIL_SEND, + + /** The group is disconnected. */ + DISCONNECTED, + } + + constructor(code: Code) : this(code, "") + + constructor(code: Code, message: String) : super(code, message) +} diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxNewException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxNewException.kt index 071bcd369..8cedc9b10 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxNewException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxNewException.kt @@ -4,61 +4,47 @@ import im.tox.tox4j.exceptions.ToxException class ToxNewException : ToxException { enum class Code { - /** - * The data format was invalid. This can happen when loading data that was - * saved by an older version of Tox, or when the data has been corrupted. - * When loading from badly formatted data, some data may have been loaded, - * and the rest is discarded. Passing an invalid length parameter also - * causes this error. - */ - LOAD_BAD_FORMAT, - - /** - * The byte array to be loaded contained an encrypted save. - */ - LOAD_ENCRYPTED, + /** One of the arguments to the function was NULL when it was not expected. */ + NULL, /** - * The function was unable to allocate enough memory to store the internal - * structures for the Tox object. + * The function was unable to allocate enough memory to store the internal structures for + * the Tox object. */ MALLOC, /** - * An argument was null. - */ - NULL, - - /** - * The function was unable to bind to a port. This may mean that all ports - * have already been bound, e.g. by other Tox instances, or it may mean - * a permission error. You may be able to gather more information from errno. + * The function was unable to bind to a port. This may mean that all ports have already been + * bound, e.g. by other Tox instances, or it may mean a permission error. You may be able to + * gather more information from errno. */ PORT_ALLOC, - /** - * {@link im.tox.tox4j.core.ToxOptions#proxyType} was valid, - * but the {@link im.tox.tox4j.core.ToxOptions#proxyAddress} passed had an invalid format. - */ + /** proxy_type was invalid. */ + PROXY_BAD_TYPE, + + /** proxy_type was valid but the proxy_host passed had an invalid format or was NULL. */ PROXY_BAD_HOST, - /** - * {@link im.tox.tox4j.core.ToxOptions#proxyType} was valid, - * but the {@link im.tox.tox4j.core.ToxOptions#proxyPort} was invalid. - */ + /** proxy_type was valid, but the proxy_port was invalid. */ PROXY_BAD_PORT, - /** - * {@link im.tox.tox4j.core.ToxOptions#proxyType} was invalid. - */ - PROXY_BAD_TYPE, + /** The proxy address passed could not be resolved. */ + PROXY_NOT_FOUND, + + /** The byte array to be loaded contained an encrypted save. */ + LOAD_ENCRYPTED, /** - * The proxy address passed could not be resolved. + * The data format was invalid. This can happen when loading data that was saved by an older + * version of Tox, or when the data has been corrupted. When loading from badly formatted + * data, some data may have been loaded, and the rest is discarded. Passing an invalid + * length parameter also causes this error. */ - PROXY_NOT_FOUND, + LOAD_BAD_FORMAT, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetInfoException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetInfoException.kt index 057920823..92f74ed89 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetInfoException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetInfoException.kt @@ -4,17 +4,14 @@ import im.tox.tox4j.exceptions.ToxException class ToxSetInfoException : ToxException { enum class Code { - /** - * An argument was null. - */ + /** One of the arguments to the function was NULL when it was not expected. */ NULL, - /** - * Information length exceeded maximum permissible size. - */ + /** Information length exceeded maximum permissible size. */ TOO_LONG, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetTypingException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetTypingException.kt index f5bfaaca7..7999781a2 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetTypingException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/ToxSetTypingException.kt @@ -4,12 +4,11 @@ import im.tox.tox4j.exceptions.ToxException class ToxSetTypingException : ToxException { enum class Code { - /** - * The friendNumber passed did not designate a valid friend. - */ + /** The friend number did not designate a valid friend. */ FRIEND_NOT_FOUND, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/exceptions.json b/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/exceptions.json deleted file mode 100644 index 85d1a2501..000000000 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/exceptions/exceptions.json +++ /dev/null @@ -1,228 +0,0 @@ -[ - "core", - "", - { - "Bootstrap": { - "NULL": ["An argument was null."], - "BAD_HOST": [ - "The address could not be resolved to an IP address, or the IP address", - "passed was invalid." - ], - "BAD_PORT": [ - "The port passed was invalid. The valid port range is (1, 65535)." - ], - "@JavaOnly BAD_KEY": ["The public key was of invalid length."] - }, - "FileControl": { - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ], - "FRIEND_NOT_CONNECTED": [ - "This client is currently not connected to the friend." - ], - "NOT_FOUND": [ - "No file transfer with the given file number was found for the given friend." - ], - "NOT_PAUSED": [ - "A {@link ToxFileControl#RESUME} control was sent, but the file transfer is running normally." - ], - "DENIED": [ - "A {@link ToxFileControl#RESUME} control was sent, but the file transfer was paused by the other", - "party. Only the party that paused the transfer can resume it." - ], - "ALREADY_PAUSED": [ - "A {@link ToxFileControl#PAUSE} control was sent, but the file transfer was already paused." - ], - "SENDQ": [ - "An allocation error occurred while increasing the send queue size." - ] - }, - "FileSeek": { - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ], - "FRIEND_NOT_CONNECTED": [ - "This client is currently not connected to the friend." - ], - "NOT_FOUND": [ - "No file transfer with the given file number was found for the given friend." - ], - "DENIED": ["File was not in a state where it could be seeked."], - "INVALID_POSITION": ["Seek position was invalid."], - "SENDQ": [ - "An allocation error occurred while increasing the send queue size." - ] - }, - "FileSendChunk": { - "NULL": ["An argument was null."], - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ], - "FRIEND_NOT_CONNECTED": [ - "This client is currently not connected to the friend." - ], - "NOT_FOUND": [ - "No file transfer with the given file number was found for the given friend." - ], - "NOT_TRANSFERRING": [ - "File transfer was found but isn't in a transferring state: (paused, done,", - "broken, etc...) (happens only when not called from the request chunk callback)." - ], - "INVALID_LENGTH": [ - "Attempted to send more or less data than requested. The requested data size is", - "adjusted according to maximum transmission unit and the expected end of", - "the file. Trying to send less or more than requested will return this error." - ], - "SENDQ": [ - "An allocation error occurred while increasing the send queue size." - ], - "WRONG_POSITION": ["Position parameter was wrong."] - }, - "FileSend": { - "NULL": ["An argument was null."], - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ], - "FRIEND_NOT_CONNECTED": [ - "This client is currently not connected to the friend." - ], - "NAME_TOO_LONG": [ - "Filename length exceeded {@link ToxCoreConstants#MAX_FILENAME_LENGTH} bytes." - ], - "TOO_MANY": [ - "Too many ongoing transfers. The maximum number of concurrent file transfers", - "is 256 per friend per direction (sending and receiving, so 512 total)." - ] - }, - "FileGet": { - "NULL": ["An argument was null."], - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ], - "NOT_FOUND": [ - "No file transfer with the given file number was found for the given friend." - ] - }, - "FriendAdd": { - "NULL": ["An argument was null."], - "TOO_LONG": [ - "The length of the friend request message exceeded {@link ToxCoreConstants#MAX_FRIEND_REQUEST_LENGTH}." - ], - "NO_MESSAGE": [ - "The friend request message was empty. This, and the TOO_LONG code will", - "never be returned from {@link ToxCore#addFriendNoRequest}." - ], - "OWN_KEY": ["The friend address belongs to the sending client."], - "ALREADY_SENT": [ - "A friend request has already been sent, or the address belongs to a friend", - "that is already on the friend list. To resend a friend request, first remove", - "the friend, and then call addFriend again." - ], - "BAD_CHECKSUM": ["The friend address checksum failed."], - "SET_NEW_NOSPAM": [ - "The friend was already on the friend list, but the noSpam value was different." - ], - "MALLOC": [ - "A memory allocation failed when trying to increase the friend list size." - ] - }, - "FriendByPublicKey": { - "NULL": ["An argument was null."], - "NOT_FOUND": [ - "No friend with the given Public Key exists on the friend list." - ] - }, - "FriendDelete": { - "FRIEND_NOT_FOUND": [ - "There was no friend with the given friend number. No friends were deleted." - ] - }, - "FriendGetPublicKey": { - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ] - }, - "GetPort": { - "NOT_BOUND": ["The instance was not bound to any port."] - }, - "New": { - "NULL": ["An argument was null."], - "MALLOC": [ - "The function was unable to allocate enough memory to store the internal", - "structures for the Tox object." - ], - "PORT_ALLOC": [ - "The function was unable to bind to a port. This may mean that all ports", - "have already been bound, e.g. by other Tox instances, or it may mean", - "a permission error. You may be able to gather more information from errno." - ], - "PROXY_BAD_TYPE": [ - "{@link im.tox.tox4j.core.ToxOptions#proxyType} was invalid." - ], - "PROXY_BAD_HOST": [ - "{@link im.tox.tox4j.core.ToxOptions#proxyType} was valid,", - "but the {@link im.tox.tox4j.core.ToxOptions#proxyAddress} passed had an invalid format." - ], - "PROXY_BAD_PORT": [ - "{@link im.tox.tox4j.core.ToxOptions#proxyType} was valid,", - "but the {@link im.tox.tox4j.core.ToxOptions#proxyPort} was invalid." - ], - "PROXY_NOT_FOUND": ["The proxy address passed could not be resolved."], - "LOAD_ENCRYPTED": [ - "The byte array to be loaded contained an encrypted save." - ], - "LOAD_BAD_FORMAT": [ - "The data format was invalid. This can happen when loading data that was", - "saved by an older version of Tox, or when the data has been corrupted.", - "When loading from badly formatted data, some data may have been loaded,", - "and the rest is discarded. Passing an invalid length parameter also", - "causes this error." - ] - }, - "FriendCustomPacket": { - "NULL": ["An argument was null."], - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ], - "FRIEND_NOT_CONNECTED": [ - "This client is currently not connected to the friend." - ], - "INVALID": [ - "The first byte of data was not in the specified range for the packet type.", - "This range is 200-254 for lossy, and 160-191 for lossless packets." - ], - "EMPTY": ["Attempted to send an empty packet."], - "TOO_LONG": [ - "Packet data length exceeded {@link ToxCoreConstants#MAX_CUSTOM_PACKET_SIZE}." - ], - "SENDQ": [ - "An allocation error occurred while increasing the send queue size." - ] - }, - "FriendSendMessage": { - "NULL": ["An argument was null."], - "FRIEND_NOT_FOUND": [ - "The friend number did not designate a valid friend." - ], - "FRIEND_NOT_CONNECTED": [ - "This client is currently not connected to the friend." - ], - "SENDQ": [ - "An allocation error occurred while increasing the send queue size." - ], - "TOO_LONG": [ - "Message length exceeded {@link ToxCoreConstants#MAX_MESSAGE_LENGTH}." - ], - "EMPTY": ["Attempted to send a zero-length message."] - }, - "SetInfo": { - "NULL": ["An argument was null."], - "TOO_LONG": ["Information length exceeded maximum permissible size."] - }, - "SetTyping": { - "FRIEND_NOT_FOUND": [ - "The friendNumber passed did not designate a valid friend." - ] - } - } -] diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/core/options/SaveDataOptions.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/core/options/SaveDataOptions.kt index f2a206c60..7729a9b25 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/core/options/SaveDataOptions.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/core/options/SaveDataOptions.kt @@ -31,9 +31,9 @@ object SaveDataOptions { } /** - * Minimal save data with just the secret key. The public key can be derived from it. Saving this - * secret key, the friend list, name, and noSpam value is sufficient to restore the observable - * behaviour of a Tox instance without the full save data in [[ToxSave]]. + * Minimal save data with just the secret key. The public key can be derived from it. Saving + * this secret key, the friend list, name, and noSpam value is sufficient to restore the + * observable behaviour of a Tox instance without the full save data in [[ToxSave]]. */ final data class SecretKey(private val key: ToxSecretKey) : Type { override val kind: ToxSavedataType = ToxSavedataType.SECRET_KEY diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCrypto.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCrypto.kt index 0162e7c35..b45258a03 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCrypto.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCrypto.kt @@ -39,11 +39,11 @@ interface ToxCrypto { /** * Generates a secret symmetric key from the given passphrase. * - * Be sure to not compromise the key! Only keep it in memory, do not write to disk. The key should - * only be used with the other functions in this module, as it includes a salt. + * Be sure to not compromise the key! Only keep it in memory, do not write to disk. The key + * should only be used with the other functions in this module, as it includes a salt. * - * Note that this function is not deterministic; to derive the same key from a password, you also - * must know the random salt that was used. See below. + * Note that this function is not deterministic; to derive the same key from a password, you + * also must know the random salt that was used. See below. * * @param passphrase A non-empty byte array containing the passphrase. * @return the generated symmetric key. @@ -68,8 +68,8 @@ interface ToxCrypto { * [[passKeyDeriveWithSalt]] to produce the same key as was previously used. Any encrypted data * with this module can be used as input. * - * Success does not say anything about the validity of the data, only that data of the appropriate - * size was copied. + * Success does not say anything about the validity of the data, only that data of the + * appropriate size was copied. * * @return the salt, or an empty array if the magic number did not match. * @throws ToxGetSaltException @@ -113,8 +113,9 @@ interface ToxCrypto { /** * Generates a cryptographic hash of the given data. * - * This function may be used by clients for any purpose, but is provided primarily for validating - * cached avatars. This use is highly recommended to avoid unnecessary avatar updates. + * This function may be used by clients for any purpose, but is provided primarily for + * validating cached avatars. This use is highly recommended to avoid unnecessary avatar + * updates. * * This function is a wrapper to internal message-digest functions. * diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCryptoConstants.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCryptoConstants.kt index 8450cb7a0..97761afcf 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCryptoConstants.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/ToxCryptoConstants.kt @@ -5,8 +5,8 @@ object ToxCryptoConstants { const val SALT_LENGTH = 32 /** - * The number of bytes in a serialised [[ToxCrypto.PassKey]] without salt. The serialised size is - * [[KEY_LENGTH]] + [[SALT_LENGTH]]. + * The number of bytes in a serialised [[ToxCrypto.PassKey]] without salt. The serialised size + * is [[KEY_LENGTH]] + [[SALT_LENGTH]]. */ const val KEY_LENGTH = 32 diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxDecryptionException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxDecryptionException.kt index b79de372c..25d41f04c 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxDecryptionException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxDecryptionException.kt @@ -5,36 +5,33 @@ import im.tox.tox4j.exceptions.ToxException class ToxDecryptionException : ToxException { enum class Code { /** - * The input data is missing the magic number (i.e. wasn't created by this - * module, or is corrupted) + * The input data is missing the magic number (i.e. wasn't created by this module, or is + * corrupted) */ BAD_FORMAT, /** - * The encrypted byte array could not be decrypted. Either the data was - * corrupt or the password/key was incorrect. + * The encrypted byte array could not be decrypted. Either the data was corrupt or the + * password/key was incorrect. */ FAILED, /** - * The input data was shorter than {@link - * ToxCryptoConstants.ENCRYPTION_EXTRA_LENGTH} bytes. + * The input data was shorter than {@link ToxCryptoConstants.ENCRYPTION_EXTRA_LENGTH} bytes. */ INVALID_LENGTH, /** - * The crypto lib was unable to derive a key from the given passphrase, - * which is usually a lack of memory issue. The functions accepting keys - * do not produce this error. + * The crypto lib was unable to derive a key from the given passphrase, which is usually a + * lack of memory issue. The functions accepting keys do not produce this error. */ KEY_DERIVATION_FAILED, - /** - * The key or input data was null or empty. - */ + /** The key or input data was null or empty. */ NULL, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxEncryptionException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxEncryptionException.kt index b1c4c9ab5..3342d9ee2 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxEncryptionException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxEncryptionException.kt @@ -4,24 +4,20 @@ import im.tox.tox4j.exceptions.ToxException class ToxEncryptionException : ToxException { enum class Code { - /** - * The encryption itself failed. - */ + /** The encryption itself failed. */ FAILED, /** - * The crypto lib was unable to derive a key from the given passphrase, - * which is usually a lack of memory issue. The functions accepting keys - * do not produce this error. + * The crypto lib was unable to derive a key from the given passphrase, which is usually a + * lack of memory issue. The functions accepting keys do not produce this error. */ KEY_DERIVATION_FAILED, - /** - * The key or input data was null or empty. - */ + /** The key or input data was null or empty. */ NULL, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxGetSaltException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxGetSaltException.kt index b134f9ff3..1017a3787 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxGetSaltException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxGetSaltException.kt @@ -5,17 +5,16 @@ import im.tox.tox4j.exceptions.ToxException class ToxGetSaltException : ToxException { enum class Code { /** - * The input data is missing the magic number (i.e. wasn't created by this - * module, or is corrupted) + * The input data is missing the magic number (i.e. wasn't created by this module, or is + * corrupted) */ BAD_FORMAT, - /** - * The data or salt were null. - */ + /** The data or salt were null. */ NULL, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxKeyDerivationException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxKeyDerivationException.kt index cfa84655e..16c20c423 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxKeyDerivationException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/crypto/exceptions/ToxKeyDerivationException.kt @@ -5,24 +5,20 @@ import im.tox.tox4j.exceptions.ToxException class ToxKeyDerivationException : ToxException { enum class Code { - /** - * The salt was of incorrect length. - */ + /** The salt was of incorrect length. */ @JavaOnly INVALID_LENGTH, /** - * The crypto lib was unable to derive a key from the given passphrase, - * which is usually a lack of memory issue. The functions accepting keys - * do not produce this error. + * The crypto lib was unable to derive a key from the given passphrase, which is usually a + * lack of memory issue. The functions accepting keys do not produce this error. */ FAILED, - /** - * The passphrase was null or empty. - */ + /** The passphrase was null or empty. */ NULL, } constructor(code: Code) : this(code, "") + constructor(code: Code, message: String) : super(code, message) } diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/JavaOnly.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/JavaOnly.kt index a67f2f75b..9c60d7177 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/JavaOnly.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/JavaOnly.kt @@ -1,9 +1,9 @@ package im.tox.tox4j.exceptions /** - * Annotation to mark error codes in Java exception enums as Java-only, so they - * are not emitted as part of the error code conversion fragments in C++ (see - * {@link im.tox.tox4j.impl.jni.codegen.JniErrorCodes}). + * Annotation to mark error codes in Java exception enums as Java-only, so they are not emitted as + * part of the error code conversion fragments in C++ (see {@link + * im.tox.tox4j.impl.jni.codegen.JniErrorCodes}). */ @Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.FIELD) diff --git a/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/ToxKilledException.kt b/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/ToxKilledException.kt index 620fbbcc4..1d13d797c 100644 --- a/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/ToxKilledException.kt +++ b/lib/src/commonMain/kotlin/im/tox/tox4j/exceptions/ToxKilledException.kt @@ -1,8 +1,7 @@ package im.tox.tox4j.exceptions /** - * Exception to be thrown when a method is invoked on a tox instance that has - * been closed. + * Exception to be thrown when a method is invoked on a tox instance that has been closed. * * @author Simon Levermann (sonOfRa) */ diff --git a/lib/src/jvmMain/cpp/CMakeLists.txt b/lib/src/jvmMain/cpp/CMakeLists.txt index 85e364ba3..9a80bde39 100644 --- a/lib/src/jvmMain/cpp/CMakeLists.txt +++ b/lib/src/jvmMain/cpp/CMakeLists.txt @@ -41,12 +41,9 @@ add_library( ToxCore/generated/impls.h ToxCore/generated/im_tox_tox4j_impl_jni_ToxCoreJni.h ToxCore/generated/natives.h - ToxCore/clientinfo.cpp ToxCore/connection.cpp - ToxCore/custom.cpp ToxCore/filetransfer.cpp ToxCore/friendlist.cpp - ToxCore/interaction.cpp ToxCore/lifecycle.cpp ToxCore/ToxCore.cpp ToxCore/ToxCore.h diff --git a/lib/src/jvmMain/cpp/ToxAv/ToxAv.h b/lib/src/jvmMain/cpp/ToxAv/ToxAv.h index 1336179a8..fc93da3f1 100644 --- a/lib/src/jvmMain/cpp/ToxAv/ToxAv.h +++ b/lib/src/jvmMain/cpp/ToxAv/ToxAv.h @@ -12,6 +12,7 @@ #ifndef SUBSYSTEM #define SUBSYSTEM TOXAV +#define STRUCT Toxav #define CLASS ToxAv #define PREFIX toxav #endif diff --git a/lib/src/jvmMain/cpp/ToxAv/generated/errors.cpp b/lib/src/jvmMain/cpp/ToxAv/generated/errors.cpp index c361add52..bc4f1fd34 100644 --- a/lib/src/jvmMain/cpp/ToxAv/generated/errors.cpp +++ b/lib/src/jvmMain/cpp/ToxAv/generated/errors.cpp @@ -1,6 +1,6 @@ #include "../ToxAv.h" -HANDLE ("Answer", ANSWER) +HANDLE ("Answer", Answer) { switch (error) { @@ -14,7 +14,7 @@ HANDLE ("Answer", ANSWER) return unhandled (); } -HANDLE ("BitRateSet", BIT_RATE_SET) +HANDLE ("BitRateSet", Bit_Rate_Set) { switch (error) { @@ -27,7 +27,7 @@ HANDLE ("BitRateSet", BIT_RATE_SET) return unhandled (); } -HANDLE ("CallControl", CALL_CONTROL) +HANDLE ("CallControl", Call_Control) { switch (error) { @@ -40,7 +40,7 @@ HANDLE ("CallControl", CALL_CONTROL) return unhandled (); } -HANDLE ("Call", CALL) +HANDLE ("Call", Call) { switch (error) { @@ -55,7 +55,7 @@ HANDLE ("Call", CALL) return unhandled (); } -HANDLE ("New", NEW) +HANDLE ("New", New) { switch (error) { @@ -67,7 +67,7 @@ HANDLE ("New", NEW) return unhandled (); } -HANDLE ("SendFrame", SEND_FRAME) +HANDLE ("SendFrame", Send_Frame) { switch (error) { diff --git a/lib/src/jvmMain/cpp/ToxCore/ToxCore.h b/lib/src/jvmMain/cpp/ToxCore/ToxCore.h index f6280b6d4..1b96a0ed8 100644 --- a/lib/src/jvmMain/cpp/ToxCore/ToxCore.h +++ b/lib/src/jvmMain/cpp/ToxCore/ToxCore.h @@ -12,6 +12,7 @@ #ifndef SUBSYSTEM #define SUBSYSTEM TOX +#define STRUCT Tox #define CLASS ToxCore #define PREFIX tox #endif @@ -67,6 +68,56 @@ struct get_vector } }; +template< + typename ConvertT, + typename GetSize, + typename GetData +> +class get_vector_err; + +template< + typename ConvertT, typename ...GetSizeArgs, typename ...GetDataArgs +> +class get_vector_err +{ + using ValueT = std::remove_pointer_t>>; + + template + static auto indices_impl(F f, std::index_sequence) { + return f(std::integral_constant()...); + } + + template + static auto indices(F f) { + return indices_impl(f, std::make_index_sequence()); + } + + template + static auto drop_last(F f, Ts... ts) { + return indices([&](auto... Is){ + auto tuple = std::make_tuple(ts...); + return f(std::get(tuple)...); + }); + } + +public: + template + static std::vector + make (GetSizeArgs ...args) + { + std::vector vec(get_size(args...)); + if (!drop_last([&](auto ...argsWithoutErr) { + // Ignore error here. If get_size failed, then get_data will fail in the same way. + return get_data(argsWithoutErr..., vec.data(), nullptr); + }, args...)) { + // It failed, don't try the conversion. + return {}; + } + + return convert_vector::value(std::move(vec)); + } +}; + template struct constant_size diff --git a/lib/src/jvmMain/cpp/ToxCore/clientinfo.cpp b/lib/src/jvmMain/cpp/ToxCore/clientinfo.cpp deleted file mode 100644 index 7b293e71a..000000000 --- a/lib/src/jvmMain/cpp/ToxCore/clientinfo.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "ToxCore.h" - -using namespace core; - - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfGetPublicKey - * Signature: (I)[B - */ -TOX_METHOD (jbyteArray, SelfGetPublicKey, - jint instanceNumber) -{ - return instances.with_instance_noerr (env, instanceNumber, - get_vector::make, - tox_self_get_public_key>::make - ); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfGetSecretKey - * Signature: (I)[B - */ -TOX_METHOD (jbyteArray, SelfGetSecretKey, - jint instanceNumber) -{ - return instances.with_instance_noerr (env, instanceNumber, - get_vector::make, - tox_self_get_secret_key>::make - ); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfGetAddress - * Signature: (I)[B - */ -TOX_METHOD (jbyteArray, SelfGetAddress, - jint instanceNumber) -{ - return instances.with_instance_noerr (env, instanceNumber, - get_vector::make, - tox_self_get_address>::make - ); -} - - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfSetName - * Signature: (I[B)V - */ -TOX_METHOD (void, SelfSetName, - jint instanceNumber, jbyteArray name) -{ - auto name_array = fromJavaArray (env, name); - return instances.with_instance_ign (env, instanceNumber, - tox_self_set_name, name_array.data (), name_array.size ()); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfGetName - * Signature: (I)[B - */ -TOX_METHOD (jbyteArray, SelfGetName, - jint instanceNumber) -{ - return instances.with_instance_noerr (env, instanceNumber, - get_vector::make - ); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfSetStatusMessage - * Signature: (I[B)V - */ -TOX_METHOD (void, SelfSetStatusMessage, - jint instanceNumber, jbyteArray statusMessage) -{ - auto status_message_array = fromJavaArray (env, statusMessage); - return instances.with_instance_ign (env, instanceNumber, - tox_self_set_status_message, status_message_array.data (), status_message_array.size ()); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfGetStatusMessage - * Signature: (I)[B - */ -TOX_METHOD (jbyteArray, SelfGetStatusMessage, - jint instanceNumber) -{ - return instances.with_instance_noerr (env, instanceNumber, - get_vector::make - ); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfSetStatus - * Signature: (II)V - */ -TOX_METHOD (void, SelfSetStatus, - jint instanceNumber, jint status) -{ - return instances.with_instance_noerr (env, instanceNumber, - tox_self_set_status, Enum::valueOf (env, status)); -} diff --git a/lib/src/jvmMain/cpp/ToxCore/custom.cpp b/lib/src/jvmMain/cpp/ToxCore/custom.cpp deleted file mode 100644 index 3bd2718aa..000000000 --- a/lib/src/jvmMain/cpp/ToxCore/custom.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "ToxCore.h" - -using namespace core; - - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxFriendSendLossyPacket - * Signature: (II[B)V - */ -TOX_METHOD (void, FriendSendLossyPacket, - jint instanceNumber, jint friendNumber, jbyteArray packet) -{ - auto packetData = fromJavaArray (env, packet); - return instances.with_instance_ign (env, instanceNumber, - tox_friend_send_lossy_packet, friendNumber, packetData.data (), packetData.size () - ); -} - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxFriendSendLosslessPacket - * Signature: (II[B)V - */ -TOX_METHOD (void, FriendSendLosslessPacket, - jint instanceNumber, jint friendNumber, jbyteArray packet) -{ - auto packetData = fromJavaArray (env, packet); - return instances.with_instance_ign (env, instanceNumber, - tox_friend_send_lossless_packet, friendNumber, packetData.data (), packetData.size () - ); -} diff --git a/lib/src/jvmMain/cpp/ToxCore/friendlist.cpp b/lib/src/jvmMain/cpp/ToxCore/friendlist.cpp index 407ef6e2c..c5a189c39 100644 --- a/lib/src/jvmMain/cpp/ToxCore/friendlist.cpp +++ b/lib/src/jvmMain/cpp/ToxCore/friendlist.cpp @@ -8,8 +8,8 @@ using namespace core; * Method: toxFriendAdd * Signature: (I[B[B)I */ -TOX_METHOD (jint, FriendAdd, - jint instanceNumber, jbyteArray address, jbyteArray message) +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendAdd + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray address, jbyteArray message) { auto messageData = fromJavaArray (env, message); auto addressData = fromJavaArray (env, address); @@ -25,8 +25,8 @@ TOX_METHOD (jint, FriendAdd, * Method: toxFriendAddNorequest * Signature: (I[B)I */ -TOX_METHOD (jint, FriendAddNorequest, - jint instanceNumber, jbyteArray publicKey) +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendAddNorequest + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray publicKey) { auto public_key = fromJavaArray (env, publicKey); tox4j_assert (!publicKey || public_key.size () == TOX_PUBLIC_KEY_SIZE); @@ -41,8 +41,8 @@ TOX_METHOD (jint, FriendAddNorequest, * Method: toxFriendDelete * Signature: (II)V */ -TOX_METHOD (void, FriendDelete, - jint instanceNumber, jint friendNumber) +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendDelete + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber) { return instances.with_instance_ign (env, instanceNumber, tox_friend_delete, friendNumber @@ -54,8 +54,8 @@ TOX_METHOD (void, FriendDelete, * Method: toxFriendByPublicKey * Signature: (I[B)I */ -TOX_METHOD (jint, FriendByPublicKey, - jint instanceNumber, jbyteArray publicKey) +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendByPublicKey + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray publicKey) { auto public_key = fromJavaArray (env, publicKey); tox4j_assert (!publicKey || public_key.size () == TOX_PUBLIC_KEY_SIZE); @@ -70,8 +70,8 @@ TOX_METHOD (jint, FriendByPublicKey, * Method: toxFriendGetPublicKey * Signature: (II)[B */ -TOX_METHOD (jbyteArray, FriendGetPublicKey, - jint instanceNumber, jint friendNumber) +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendGetPublicKey + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber) { uint8_t public_key[TOX_PUBLIC_KEY_SIZE]; return instances.with_instance_err (env, instanceNumber, @@ -88,8 +88,8 @@ TOX_METHOD (jbyteArray, FriendGetPublicKey, * Method: toxSelfGetFriendList * Signature: (I)[I */ -TOX_METHOD (jintArray, SelfGetFriendList, - jint instanceNumber) +JNIEXPORT jintArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfGetFriendList + (JNIEnv *env, jclass, jint instanceNumber) { return instances.with_instance_noerr (env, instanceNumber, get_vector::make ); } + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfSetTyping + * Signature: (IIZ)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfSetTyping + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jboolean isTyping) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_self_set_typing, friendNumber, isTyping + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxFriendSendMessage + * Signature: (III[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendSendMessage + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jint messageType, jbyteArray message) +{ + auto message_array = fromJavaArray (env, message); + + return instances.with_instance_err (env, instanceNumber, + identity, + tox_friend_send_message, friendNumber, Enum::valueOf (env, messageType), message_array.data (), message_array.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxFriendSendLossyPacket + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendSendLossyPacket + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jbyteArray packet) +{ + auto packetData = fromJavaArray (env, packet); + return instances.with_instance_ign (env, instanceNumber, + tox_friend_send_lossy_packet, friendNumber, packetData.data (), packetData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxFriendSendLosslessPacket + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendSendLosslessPacket + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jbyteArray packet) +{ + auto packetData = fromJavaArray (env, packet); + return instances.with_instance_ign (env, instanceNumber, + tox_friend_send_lossless_packet, friendNumber, packetData.data (), packetData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfGetPublicKey + * Signature: (I)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfGetPublicKey + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_noerr (env, instanceNumber, + get_vector::make, + tox_self_get_public_key>::make + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfGetSecretKey + * Signature: (I)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfGetSecretKey + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_noerr (env, instanceNumber, + get_vector::make, + tox_self_get_secret_key>::make + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfGetAddress + * Signature: (I)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfGetAddress + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_noerr (env, instanceNumber, + get_vector::make, + tox_self_get_address>::make + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfSetName + * Signature: (I[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfSetName + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray name) +{ + auto name_array = fromJavaArray (env, name); + return instances.with_instance_ign (env, instanceNumber, + tox_self_set_name, name_array.data (), name_array.size ()); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfGetName + * Signature: (I)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfGetName + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_noerr (env, instanceNumber, + get_vector::make + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfSetStatusMessage + * Signature: (I[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfSetStatusMessage + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray statusMessage) +{ + auto status_message_array = fromJavaArray (env, statusMessage); + return instances.with_instance_ign (env, instanceNumber, + tox_self_set_status_message, status_message_array.data (), status_message_array.size ()); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfGetStatusMessage + * Signature: (I)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfGetStatusMessage + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_noerr (env, instanceNumber, + get_vector::make + ); +} + +/* + * Class: im_tox_tox4j_impl_ToxCoreJni + * Method: toxSelfSetStatus + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfSetStatus + (JNIEnv *env, jclass, jint instanceNumber, jint status) +{ + return instances.with_instance_noerr (env, instanceNumber, + tox_self_set_status, Enum::valueOf (env, status)); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceNew + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceNew + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_new + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceDelete + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceDelete + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_conference_delete, conferenceNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerCount + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerCount + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_peer_count, conferenceNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerGetName + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerGetName + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint peerNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_conference_peer_get_name_size, + tox_conference_peer_get_name>, conferenceNumber, peerNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerGetPublicKey + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerGetPublicKey + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint peerNumber); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerNumberIsOurs + * Signature: (III)Z + */ +JNIEXPORT jboolean JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerNumberIsOurs + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint peerNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_peer_number_is_ours, conferenceNumber, peerNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerCount + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerCount + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_offline_peer_count, conferenceNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerGetName + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerGetName + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint offlinePeerNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_conference_offline_peer_get_name_size, + tox_conference_offline_peer_get_name>, conferenceNumber, offlinePeerNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerGetPublicKey + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerGetPublicKey + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint offlinePeerNumber); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerGetLastActive + * Signature: (III)J + */ +JNIEXPORT jlong JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerGetLastActive + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint offlinePeerNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_offline_peer_get_last_active, conferenceNumber, offlinePeerNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceSetMaxOffline + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceSetMaxOffline + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint maxOffline) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_conference_set_max_offline, conferenceNumber, maxOffline + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceInvite + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceInvite + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jint conferenceNumber) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_conference_invite, friendNumber, conferenceNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceJoin + * Signature: (II[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceJoin + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jbyteArray cookie) +{ + auto cookieData = fromJavaArray (env, cookie); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_join, friendNumber, cookieData.data (), cookieData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceSendMessage + * Signature: (III[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceSendMessage + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jint type, jbyteArray message) +{ + auto messageData = fromJavaArray (env, message); + return instances.with_instance_ign (env, instanceNumber, + tox_conference_send_message, conferenceNumber, Enum::valueOf (env, type), messageData.data (), messageData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetTitle + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetTitle + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_conference_get_title_size, + tox_conference_get_title>, conferenceNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceSetTitle + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceSetTitle + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber, jbyteArray title) +{ + auto titleData = fromJavaArray (env, title); + return instances.with_instance_ign (env, instanceNumber, + tox_conference_set_title, conferenceNumber, titleData.data (), titleData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetChatlist + * Signature: (I)[I + */ +JNIEXPORT jintArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetChatlist + (JNIEnv *env, jclass, jint instanceNumber) +{ + return instances.with_instance_noerr (env, instanceNumber, + get_vector::make + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetType + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetType + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_get_type, conferenceNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetId + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetId + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceById + * Signature: (I[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceById + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray id) +{ + auto idData = fromJavaArray (env, id); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_by_id, idData.data () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetUid + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetUid + (JNIEnv *env, jclass, jint instanceNumber, jint conferenceNumber); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceByUid + * Signature: (I[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceByUid + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray uid) +{ + auto uidData = fromJavaArray (env, uid); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_conference_by_uid, uidData.data () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupNew + * Signature: (II[B[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupNew + (JNIEnv *env, jclass, jint instanceNumber, jint privacyState, jbyteArray groupName, jbyteArray name) +{ + auto groupNameData = fromJavaArray (env, groupName); + auto nameData = fromJavaArray (env, name); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_new, Enum::valueOf (env, privacyState), groupNameData.data (), groupNameData.size (), nameData.data (), nameData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupJoin + * Signature: (I[B[B[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupJoin + (JNIEnv *env, jclass, jint instanceNumber, jbyteArray chatId, jbyteArray name, jbyteArray password) +{ + auto chatIdData = fromJavaArray (env, chatId); + tox4j_assert (!chatId || chatIdData.size () == TOX_GROUP_CHAT_ID_SIZE); + auto nameData = fromJavaArray (env, name); + auto passwordData = fromJavaArray (env, password); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_join, chatIdData, nameData.data (), nameData.size (), passwordData.data (), passwordData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupIsConnected + * Signature: (II)Z + */ +JNIEXPORT jboolean JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupIsConnected + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_is_connected, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupDisconnect + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupDisconnect + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_disconnect, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupReconnect + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupReconnect + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_reconnect, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupLeave + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupLeave + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jbyteArray partMessage) +{ + auto partMessageData = fromJavaArray (env, partMessage); + return instances.with_instance_ign (env, instanceNumber, + tox_group_leave, groupNumber, partMessageData.data (), partMessageData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfSetName + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfSetName + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jbyteArray name) +{ + auto nameData = fromJavaArray (env, name); + return instances.with_instance_ign (env, instanceNumber, + tox_group_self_set_name, groupNumber, nameData.data (), nameData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetName + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetName + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_group_self_get_name_size, + tox_group_self_get_name>, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfSetStatus + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfSetStatus + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint status) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_self_set_status, groupNumber, Enum::valueOf (env, status) + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetStatus + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetStatus + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_self_get_status, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetRole + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetRole + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_self_get_role, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetPeerId + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetPeerId + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_self_get_peer_id, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetPublicKey + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetPublicKey + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + uint8_t public_key[TOX_PUBLIC_KEY_SIZE]; + return instances.with_instance_err (env, instanceNumber, + [&] (bool) + { + return toJavaArray (env, public_key); + }, + tox_group_self_get_public_key, groupNumber, public_key + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetName + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetName + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_group_peer_get_name_size, + tox_group_peer_get_name>, groupNumber, peerId + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetStatus + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetStatus + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_peer_get_status, groupNumber, peerId + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetRole + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetRole + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_peer_get_role, groupNumber, peerId + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetConnectionStatus + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetConnectionStatus + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_peer_get_connection_status, groupNumber, peerId + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetPublicKey + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetPublicKey + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId) +{ + uint8_t public_key[TOX_PUBLIC_KEY_SIZE]; + return instances.with_instance_err (env, instanceNumber, + [&] (bool) + { + return toJavaArray (env, public_key); + }, + tox_group_peer_get_public_key, groupNumber, peerId, public_key + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetTopic + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetTopic + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jbyteArray topic) +{ + auto topicData = fromJavaArray (env, topic); + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_topic, groupNumber, topicData.data (), topicData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetTopic + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetTopic + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_group_get_topic_size, + tox_group_get_topic>, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetName + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetName + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_group_get_name_size, + tox_group_get_name>, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetChatId + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetChatId + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE]; + return instances.with_instance_err (env, instanceNumber, + [&] (bool) + { + return toJavaArray (env, chat_id); + }, + tox_group_get_chat_id, groupNumber, chat_id + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetPrivacyState + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetPrivacyState + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_get_privacy_state, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetVoiceState + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetVoiceState + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_get_voice_state, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetTopicLock + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetTopicLock + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_get_topic_lock, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetPeerLimit + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetPeerLimit + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_get_peer_limit, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetPassword + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetPassword + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber) +{ + return instances.with_instance_err (env, instanceNumber, + identity, + get_vector_err::make< + tox_group_get_password_size, + tox_group_get_password>, groupNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendMessage + * Signature: (III[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendMessage + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint type, jbyteArray message) +{ + auto messageData = fromJavaArray (env, message); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_send_message, groupNumber, Enum::valueOf (env, type), messageData.data (), messageData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendPrivateMessage + * Signature: (IIII[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendPrivateMessage + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId, jint type, jbyteArray message) +{ + auto messageData = fromJavaArray (env, message); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_send_private_message, groupNumber, peerId, Enum::valueOf (env, type), messageData.data (), messageData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendCustomPacket + * Signature: (IIZ[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendCustomPacket + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jboolean lossless, jbyteArray data) +{ + auto dataData = fromJavaArray (env, data); + return instances.with_instance_ign (env, instanceNumber, + tox_group_send_custom_packet, groupNumber, lossless, dataData.data (), dataData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendCustomPrivatePacket + * Signature: (IIIZ[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendCustomPrivatePacket + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId, jboolean lossless, jbyteArray data) +{ + auto dataData = fromJavaArray (env, data); + return instances.with_instance_ign (env, instanceNumber, + tox_group_send_custom_private_packet, groupNumber, peerId, lossless, dataData.data (), dataData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupInviteFriend + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupInviteFriend + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint friendNumber) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_invite_friend, groupNumber, friendNumber + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupInviteAccept + * Signature: (II[B[B[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupInviteAccept + (JNIEnv *env, jclass, jint instanceNumber, jint friendNumber, jbyteArray inviteData, jbyteArray name, jbyteArray password) +{ + auto inviteDataData = fromJavaArray (env, inviteData); + auto nameData = fromJavaArray (env, name); + auto passwordData = fromJavaArray (env, password); + return instances.with_instance_err (env, instanceNumber, + identity, + tox_group_invite_accept, friendNumber, inviteDataData.data (), inviteDataData.size (), nameData.data (), nameData.size (), passwordData.data (), passwordData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetPassword + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetPassword + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jbyteArray password) +{ + auto passwordData = fromJavaArray (env, password); + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_password, groupNumber, passwordData.data (), passwordData.size () + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetTopicLock + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetTopicLock + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint topicLock) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_topic_lock, groupNumber, Enum::valueOf (env, topicLock) + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetVoiceState + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetVoiceState + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint voiceState) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_voice_state, groupNumber, Enum::valueOf (env, voiceState) + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetPrivacyState + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetPrivacyState + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint privacyState) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_privacy_state, groupNumber, Enum::valueOf (env, privacyState) + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetPeerLimit + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetPeerLimit + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerLimit) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_peer_limit, groupNumber, peerLimit + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetIgnore + * Signature: (IIIZ)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetIgnore + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId, jboolean ignore) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_ignore, groupNumber, peerId, ignore + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetRole + * Signature: (IIII)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetRole + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId, jint role) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_set_role, groupNumber, peerId, Enum::valueOf (env, role) + ); +} + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupKickPeer + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupKickPeer + (JNIEnv *env, jclass, jint instanceNumber, jint groupNumber, jint peerId) +{ + return instances.with_instance_ign (env, instanceNumber, + tox_group_kick_peer, groupNumber, peerId + ); +} diff --git a/lib/src/jvmMain/cpp/ToxCore/generated/enums.cpp b/lib/src/jvmMain/cpp/ToxCore/generated/enums.cpp index 9d3cc7b82..ca31d22ca 100644 --- a/lib/src/jvmMain/cpp/ToxCore/generated/enums.cpp +++ b/lib/src/jvmMain/cpp/ToxCore/generated/enums.cpp @@ -2,7 +2,7 @@ template<> jint -Enum::ordinal (JNIEnv *env, TOX_CONNECTION valueOf) +Enum::ordinal (JNIEnv *env, Tox_Connection valueOf) { switch (valueOf) { @@ -14,8 +14,8 @@ Enum::ordinal (JNIEnv *env, TOX_CONNECTION valueOf) } template<> -TOX_CONNECTION -Enum::valueOf (JNIEnv *env, jint ordinal) +Tox_Connection +Enum::valueOf (JNIEnv *env, jint ordinal) { switch (ordinal) { @@ -28,7 +28,7 @@ Enum::valueOf (JNIEnv *env, jint ordinal) template<> jint -Enum::ordinal (JNIEnv *env, TOX_FILE_CONTROL valueOf) +Enum::ordinal (JNIEnv *env, Tox_File_Control valueOf) { switch (valueOf) { @@ -40,8 +40,8 @@ Enum::ordinal (JNIEnv *env, TOX_FILE_CONTROL valueOf) } template<> -TOX_FILE_CONTROL -Enum::valueOf (JNIEnv *env, jint ordinal) +Tox_File_Control +Enum::valueOf (JNIEnv *env, jint ordinal) { switch (ordinal) { @@ -54,7 +54,7 @@ Enum::valueOf (JNIEnv *env, jint ordinal) template<> jint -Enum::ordinal (JNIEnv *env, TOX_MESSAGE_TYPE valueOf) +Enum::ordinal (JNIEnv *env, Tox_Message_Type valueOf) { switch (valueOf) { @@ -65,8 +65,8 @@ Enum::ordinal (JNIEnv *env, TOX_MESSAGE_TYPE valueOf) } template<> -TOX_MESSAGE_TYPE -Enum::valueOf (JNIEnv *env, jint ordinal) +Tox_Message_Type +Enum::valueOf (JNIEnv *env, jint ordinal) { switch (ordinal) { @@ -78,7 +78,7 @@ Enum::valueOf (JNIEnv *env, jint ordinal) template<> jint -Enum::ordinal (JNIEnv *env, TOX_PROXY_TYPE valueOf) +Enum::ordinal (JNIEnv *env, Tox_Proxy_Type valueOf) { switch (valueOf) { @@ -90,8 +90,8 @@ Enum::ordinal (JNIEnv *env, TOX_PROXY_TYPE valueOf) } template<> -TOX_PROXY_TYPE -Enum::valueOf (JNIEnv *env, jint ordinal) +Tox_Proxy_Type +Enum::valueOf (JNIEnv *env, jint ordinal) { switch (ordinal) { @@ -104,7 +104,7 @@ Enum::valueOf (JNIEnv *env, jint ordinal) template<> jint -Enum::ordinal (JNIEnv *env, TOX_SAVEDATA_TYPE valueOf) +Enum::ordinal (JNIEnv *env, Tox_Savedata_Type valueOf) { switch (valueOf) { @@ -116,8 +116,8 @@ Enum::ordinal (JNIEnv *env, TOX_SAVEDATA_TYPE valueOf) } template<> -TOX_SAVEDATA_TYPE -Enum::valueOf (JNIEnv *env, jint ordinal) +Tox_Savedata_Type +Enum::valueOf (JNIEnv *env, jint ordinal) { switch (ordinal) { @@ -130,7 +130,7 @@ Enum::valueOf (JNIEnv *env, jint ordinal) template<> jint -Enum::ordinal (JNIEnv *env, TOX_USER_STATUS valueOf) +Enum::ordinal (JNIEnv *env, Tox_User_Status valueOf) { switch (valueOf) { @@ -142,8 +142,8 @@ Enum::ordinal (JNIEnv *env, TOX_USER_STATUS valueOf) } template<> -TOX_USER_STATUS -Enum::valueOf (JNIEnv *env, jint ordinal) +Tox_User_Status +Enum::valueOf (JNIEnv *env, jint ordinal) { switch (ordinal) { @@ -153,3 +153,215 @@ Enum::valueOf (JNIEnv *env, jint ordinal) } tox4j_fatal ("Invalid enumerator from Java"); } + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Conference_Type valueOf) +{ + switch (valueOf) + { + case TOX_CONFERENCE_TYPE_TEXT: return 0; + case TOX_CONFERENCE_TYPE_AV: return 1; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Conference_Type +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_CONFERENCE_TYPE_TEXT; + case 1: return TOX_CONFERENCE_TYPE_AV; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Privacy_State valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_PRIVACY_STATE_PUBLIC: return 0; + case TOX_GROUP_PRIVACY_STATE_PRIVATE: return 1; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Privacy_State +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_PRIVACY_STATE_PUBLIC; + case 1: return TOX_GROUP_PRIVACY_STATE_PRIVATE; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Topic_Lock valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_TOPIC_LOCK_ENABLED: return 0; + case TOX_GROUP_TOPIC_LOCK_DISABLED: return 1; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Topic_Lock +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_TOPIC_LOCK_ENABLED; + case 1: return TOX_GROUP_TOPIC_LOCK_DISABLED; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Voice_State valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_VOICE_STATE_ALL: return 0; + case TOX_GROUP_VOICE_STATE_MODERATOR: return 1; + case TOX_GROUP_VOICE_STATE_FOUNDER: return 2; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Voice_State +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_VOICE_STATE_ALL; + case 1: return TOX_GROUP_VOICE_STATE_MODERATOR; + case 2: return TOX_GROUP_VOICE_STATE_FOUNDER; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Role valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_ROLE_FOUNDER: return 0; + case TOX_GROUP_ROLE_MODERATOR: return 1; + case TOX_GROUP_ROLE_USER: return 2; + case TOX_GROUP_ROLE_OBSERVER: return 3; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Role +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_ROLE_FOUNDER; + case 1: return TOX_GROUP_ROLE_MODERATOR; + case 2: return TOX_GROUP_ROLE_USER; + case 3: return TOX_GROUP_ROLE_OBSERVER; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Exit_Type valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_EXIT_TYPE_QUIT: return 0; + case TOX_GROUP_EXIT_TYPE_TIMEOUT: return 1; + case TOX_GROUP_EXIT_TYPE_DISCONNECTED: return 2; + case TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED: return 3; + case TOX_GROUP_EXIT_TYPE_KICK: return 4; + case TOX_GROUP_EXIT_TYPE_SYNC_ERROR: return 5; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Exit_Type +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_EXIT_TYPE_QUIT; + case 1: return TOX_GROUP_EXIT_TYPE_TIMEOUT; + case 2: return TOX_GROUP_EXIT_TYPE_DISCONNECTED; + case 3: return TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED; + case 4: return TOX_GROUP_EXIT_TYPE_KICK; + case 5: return TOX_GROUP_EXIT_TYPE_SYNC_ERROR; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Join_Fail valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_JOIN_FAIL_PEER_LIMIT: return 0; + case TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD: return 1; + case TOX_GROUP_JOIN_FAIL_UNKNOWN: return 2; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Join_Fail +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_JOIN_FAIL_PEER_LIMIT; + case 1: return TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD; + case 2: return TOX_GROUP_JOIN_FAIL_UNKNOWN; + } + tox4j_fatal ("Invalid enumerator from Java"); +} + +template<> +jint +Enum::ordinal (JNIEnv *env, Tox_Group_Mod_Event valueOf) +{ + switch (valueOf) + { + case TOX_GROUP_MOD_EVENT_KICK: return 0; + case TOX_GROUP_MOD_EVENT_OBSERVER: return 1; + case TOX_GROUP_MOD_EVENT_USER: return 2; + case TOX_GROUP_MOD_EVENT_MODERATOR: return 3; + } + tox4j_fatal ("Invalid enumerator from toxcore"); +} + +template<> +Tox_Group_Mod_Event +Enum::valueOf (JNIEnv *env, jint ordinal) +{ + switch (ordinal) + { + case 0: return TOX_GROUP_MOD_EVENT_KICK; + case 1: return TOX_GROUP_MOD_EVENT_OBSERVER; + case 2: return TOX_GROUP_MOD_EVENT_USER; + case 3: return TOX_GROUP_MOD_EVENT_MODERATOR; + } + tox4j_fatal ("Invalid enumerator from Java"); +} diff --git a/lib/src/jvmMain/cpp/ToxCore/generated/errors.cpp b/lib/src/jvmMain/cpp/ToxCore/generated/errors.cpp index 0a7eaec31..f5ee5c806 100644 --- a/lib/src/jvmMain/cpp/ToxCore/generated/errors.cpp +++ b/lib/src/jvmMain/cpp/ToxCore/generated/errors.cpp @@ -1,6 +1,6 @@ #include "../ToxCore.h" -HANDLE ("Bootstrap", BOOTSTRAP) +HANDLE ("Bootstrap", Bootstrap) { switch (error) { @@ -12,7 +12,7 @@ HANDLE ("Bootstrap", BOOTSTRAP) return unhandled (); } -HANDLE ("FileControl", FILE_CONTROL) +HANDLE ("FileControl", File_Control) { switch (error) { @@ -28,7 +28,7 @@ HANDLE ("FileControl", FILE_CONTROL) return unhandled (); } -HANDLE ("FileGet", FILE_GET) +HANDLE ("FileGet", File_Get) { switch (error) { @@ -40,7 +40,7 @@ HANDLE ("FileGet", FILE_GET) return unhandled (); } -HANDLE ("FileSeek", FILE_SEEK) +HANDLE ("FileSeek", File_Seek) { switch (error) { @@ -55,7 +55,7 @@ HANDLE ("FileSeek", FILE_SEEK) return unhandled (); } -HANDLE ("FileSendChunk", FILE_SEND_CHUNK) +HANDLE ("FileSendChunk", File_Send_Chunk) { switch (error) { @@ -72,7 +72,7 @@ HANDLE ("FileSendChunk", FILE_SEND_CHUNK) return unhandled (); } -HANDLE ("FileSend", FILE_SEND) +HANDLE ("FileSend", File_Send) { switch (error) { @@ -86,7 +86,7 @@ HANDLE ("FileSend", FILE_SEND) return unhandled (); } -HANDLE ("FriendAdd", FRIEND_ADD) +HANDLE ("FriendAdd", Friend_Add) { switch (error) { @@ -103,7 +103,7 @@ HANDLE ("FriendAdd", FRIEND_ADD) return unhandled (); } -HANDLE ("FriendByPublicKey", FRIEND_BY_PUBLIC_KEY) +HANDLE ("FriendByPublicKey", Friend_By_Public_Key) { switch (error) { @@ -114,7 +114,7 @@ HANDLE ("FriendByPublicKey", FRIEND_BY_PUBLIC_KEY) return unhandled (); } -HANDLE ("FriendCustomPacket", FRIEND_CUSTOM_PACKET) +HANDLE ("FriendCustomPacket", Friend_Custom_Packet) { switch (error) { @@ -130,7 +130,7 @@ HANDLE ("FriendCustomPacket", FRIEND_CUSTOM_PACKET) return unhandled (); } -HANDLE ("FriendDelete", FRIEND_DELETE) +HANDLE ("FriendDelete", Friend_Delete) { switch (error) { @@ -140,7 +140,7 @@ HANDLE ("FriendDelete", FRIEND_DELETE) return unhandled (); } -HANDLE ("FriendGetPublicKey", FRIEND_GET_PUBLIC_KEY) +HANDLE ("FriendGetPublicKey", Friend_Get_Public_Key) { switch (error) { @@ -150,7 +150,7 @@ HANDLE ("FriendGetPublicKey", FRIEND_GET_PUBLIC_KEY) return unhandled (); } -HANDLE ("FriendSendMessage", FRIEND_SEND_MESSAGE) +HANDLE ("FriendSendMessage", Friend_Send_Message) { switch (error) { @@ -165,7 +165,7 @@ HANDLE ("FriendSendMessage", FRIEND_SEND_MESSAGE) return unhandled (); } -HANDLE ("GetPort", GET_PORT) +HANDLE ("GetPort", Get_Port) { switch (error) { @@ -175,7 +175,7 @@ HANDLE ("GetPort", GET_PORT) return unhandled (); } -HANDLE ("New", NEW) +HANDLE ("New", New) { switch (error) { @@ -193,7 +193,7 @@ HANDLE ("New", NEW) return unhandled (); } -HANDLE ("SetInfo", SET_INFO) +HANDLE ("SetInfo", Set_Info) { switch (error) { @@ -204,7 +204,7 @@ HANDLE ("SetInfo", SET_INFO) return unhandled (); } -HANDLE ("SetTyping", SET_TYPING) +HANDLE ("SetTyping", Set_Typing) { switch (error) { @@ -213,3 +213,478 @@ HANDLE ("SetTyping", SET_TYPING) } return unhandled (); } + +HANDLE ("ConferenceNew", Conference_New) +{ + switch (error) + { + success_case (CONFERENCE_NEW); + failure_case (CONFERENCE_NEW, INIT); + } + return unhandled (); +} + +HANDLE ("ConferenceDelete", Conference_Delete) +{ + switch (error) + { + success_case (CONFERENCE_DELETE); + failure_case (CONFERENCE_DELETE, CONFERENCE_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("ConferencePeerQuery", Conference_Peer_Query) +{ + switch (error) + { + success_case (CONFERENCE_PEER_QUERY); + failure_case (CONFERENCE_PEER_QUERY, CONFERENCE_NOT_FOUND); + failure_case (CONFERENCE_PEER_QUERY, NO_CONNECTION); + failure_case (CONFERENCE_PEER_QUERY, PEER_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("ConferenceSetMaxOffline", Conference_Set_Max_Offline) +{ + switch (error) + { + success_case (CONFERENCE_SET_MAX_OFFLINE); + failure_case (CONFERENCE_SET_MAX_OFFLINE, CONFERENCE_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("ConferenceInvite", Conference_Invite) +{ + switch (error) + { + success_case (CONFERENCE_INVITE); + failure_case (CONFERENCE_INVITE, CONFERENCE_NOT_FOUND); + failure_case (CONFERENCE_INVITE, FAIL_SEND); + failure_case (CONFERENCE_INVITE, NO_CONNECTION); + } + return unhandled (); +} + +HANDLE ("ConferenceJoin", Conference_Join) +{ + switch (error) + { + success_case (CONFERENCE_JOIN); + failure_case (CONFERENCE_JOIN, DUPLICATE); + failure_case (CONFERENCE_JOIN, FAIL_SEND); + failure_case (CONFERENCE_JOIN, FRIEND_NOT_FOUND); + failure_case (CONFERENCE_JOIN, INIT_FAIL); + failure_case (CONFERENCE_JOIN, INVALID_LENGTH); + failure_case (CONFERENCE_JOIN, WRONG_TYPE); + } + return unhandled (); +} + +HANDLE ("ConferenceSendMessage", Conference_Send_Message) +{ + switch (error) + { + success_case (CONFERENCE_SEND_MESSAGE); + failure_case (CONFERENCE_SEND_MESSAGE, CONFERENCE_NOT_FOUND); + failure_case (CONFERENCE_SEND_MESSAGE, FAIL_SEND); + failure_case (CONFERENCE_SEND_MESSAGE, NO_CONNECTION); + failure_case (CONFERENCE_SEND_MESSAGE, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("ConferenceTitle", Conference_Title) +{ + switch (error) + { + success_case (CONFERENCE_TITLE); + failure_case (CONFERENCE_TITLE, CONFERENCE_NOT_FOUND); + failure_case (CONFERENCE_TITLE, FAIL_SEND); + failure_case (CONFERENCE_TITLE, INVALID_LENGTH); + } + return unhandled (); +} + +HANDLE ("ConferenceGetType", Conference_Get_Type) +{ + switch (error) + { + success_case (CONFERENCE_GET_TYPE); + failure_case (CONFERENCE_GET_TYPE, CONFERENCE_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("ConferenceById", Conference_By_Id) +{ + switch (error) + { + success_case (CONFERENCE_BY_ID); + failure_case (CONFERENCE_BY_ID, NULL); + failure_case (CONFERENCE_BY_ID, NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("ConferenceByUid", Conference_By_Uid) +{ + switch (error) + { + success_case (CONFERENCE_BY_UID); + failure_case (CONFERENCE_BY_UID, NULL); + failure_case (CONFERENCE_BY_UID, NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupNew", Group_New) +{ + switch (error) + { + success_case (GROUP_NEW); + failure_case (GROUP_NEW, ANNOUNCE); + failure_case (GROUP_NEW, EMPTY); + failure_case (GROUP_NEW, INIT); + failure_case (GROUP_NEW, STATE); + failure_case (GROUP_NEW, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupJoin", Group_Join) +{ + switch (error) + { + success_case (GROUP_JOIN); + failure_case (GROUP_JOIN, BAD_CHAT_ID); + failure_case (GROUP_JOIN, CORE); + failure_case (GROUP_JOIN, EMPTY); + failure_case (GROUP_JOIN, INIT); + failure_case (GROUP_JOIN, PASSWORD); + failure_case (GROUP_JOIN, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupIsConnected", Group_Is_Connected) +{ + switch (error) + { + success_case (GROUP_IS_CONNECTED); + failure_case (GROUP_IS_CONNECTED, GROUP_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupDisconnect", Group_Disconnect) +{ + switch (error) + { + success_case (GROUP_DISCONNECT); + failure_case (GROUP_DISCONNECT, ALREADY_DISCONNECTED); + failure_case (GROUP_DISCONNECT, GROUP_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupReconnect", Group_Reconnect) +{ + switch (error) + { + success_case (GROUP_RECONNECT); + failure_case (GROUP_RECONNECT, CORE); + failure_case (GROUP_RECONNECT, GROUP_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupLeave", Group_Leave) +{ + switch (error) + { + success_case (GROUP_LEAVE); + failure_case (GROUP_LEAVE, FAIL_SEND); + failure_case (GROUP_LEAVE, GROUP_NOT_FOUND); + failure_case (GROUP_LEAVE, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSelfQuery", Group_Self_Query) +{ + switch (error) + { + success_case (GROUP_SELF_QUERY); + failure_case (GROUP_SELF_QUERY, GROUP_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupSelfNameSet", Group_Self_Name_Set) +{ + switch (error) + { + success_case (GROUP_SELF_NAME_SET); + failure_case (GROUP_SELF_NAME_SET, FAIL_SEND); + failure_case (GROUP_SELF_NAME_SET, GROUP_NOT_FOUND); + failure_case (GROUP_SELF_NAME_SET, INVALID); + failure_case (GROUP_SELF_NAME_SET, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSelfStatusSet", Group_Self_Status_Set) +{ + switch (error) + { + success_case (GROUP_SELF_STATUS_SET); + failure_case (GROUP_SELF_STATUS_SET, FAIL_SEND); + failure_case (GROUP_SELF_STATUS_SET, GROUP_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupPeerQuery", Group_Peer_Query) +{ + switch (error) + { + success_case (GROUP_PEER_QUERY); + failure_case (GROUP_PEER_QUERY, GROUP_NOT_FOUND); + failure_case (GROUP_PEER_QUERY, PEER_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupStateQuery", Group_State_Query) +{ + switch (error) + { + success_case (GROUP_STATE_QUERY); + failure_case (GROUP_STATE_QUERY, GROUP_NOT_FOUND); + } + return unhandled (); +} + +HANDLE ("GroupTopicSet", Group_Topic_Set) +{ + switch (error) + { + success_case (GROUP_TOPIC_SET); + failure_case (GROUP_TOPIC_SET, DISCONNECTED); + failure_case (GROUP_TOPIC_SET, FAIL_CREATE); + failure_case (GROUP_TOPIC_SET, FAIL_SEND); + failure_case (GROUP_TOPIC_SET, GROUP_NOT_FOUND); + failure_case (GROUP_TOPIC_SET, PERMISSIONS); + failure_case (GROUP_TOPIC_SET, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSendMessage", Group_Send_Message) +{ + switch (error) + { + success_case (GROUP_SEND_MESSAGE); + failure_case (GROUP_SEND_MESSAGE, BAD_TYPE); + failure_case (GROUP_SEND_MESSAGE, DISCONNECTED); + failure_case (GROUP_SEND_MESSAGE, EMPTY); + failure_case (GROUP_SEND_MESSAGE, FAIL_SEND); + failure_case (GROUP_SEND_MESSAGE, GROUP_NOT_FOUND); + failure_case (GROUP_SEND_MESSAGE, PERMISSIONS); + failure_case (GROUP_SEND_MESSAGE, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSendPrivateMessage", Group_Send_Private_Message) +{ + switch (error) + { + success_case (GROUP_SEND_PRIVATE_MESSAGE); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, BAD_TYPE); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, DISCONNECTED); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, EMPTY); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, FAIL_SEND); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, GROUP_NOT_FOUND); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, PERMISSIONS); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, PEER_NOT_FOUND); + failure_case (GROUP_SEND_PRIVATE_MESSAGE, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSendCustomPacket", Group_Send_Custom_Packet) +{ + switch (error) + { + success_case (GROUP_SEND_CUSTOM_PACKET); + failure_case (GROUP_SEND_CUSTOM_PACKET, DISCONNECTED); + failure_case (GROUP_SEND_CUSTOM_PACKET, EMPTY); + failure_case (GROUP_SEND_CUSTOM_PACKET, FAIL_SEND); + failure_case (GROUP_SEND_CUSTOM_PACKET, GROUP_NOT_FOUND); + failure_case (GROUP_SEND_CUSTOM_PACKET, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSendCustomPrivatePacket", Group_Send_Custom_Private_Packet) +{ + switch (error) + { + success_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET); + failure_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET, DISCONNECTED); + failure_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET, EMPTY); + failure_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET, FAIL_SEND); + failure_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET, GROUP_NOT_FOUND); + failure_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET, PEER_NOT_FOUND); + failure_case (GROUP_SEND_CUSTOM_PRIVATE_PACKET, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupInviteFriend", Group_Invite_Friend) +{ + switch (error) + { + success_case (GROUP_INVITE_FRIEND); + failure_case (GROUP_INVITE_FRIEND, DISCONNECTED); + failure_case (GROUP_INVITE_FRIEND, FAIL_SEND); + failure_case (GROUP_INVITE_FRIEND, FRIEND_NOT_FOUND); + failure_case (GROUP_INVITE_FRIEND, GROUP_NOT_FOUND); + failure_case (GROUP_INVITE_FRIEND, INVITE_FAIL); + } + return unhandled (); +} + +HANDLE ("GroupInviteAccept", Group_Invite_Accept) +{ + switch (error) + { + success_case (GROUP_INVITE_ACCEPT); + failure_case (GROUP_INVITE_ACCEPT, BAD_INVITE); + failure_case (GROUP_INVITE_ACCEPT, EMPTY); + failure_case (GROUP_INVITE_ACCEPT, FAIL_SEND); + failure_case (GROUP_INVITE_ACCEPT, FRIEND_NOT_FOUND); + failure_case (GROUP_INVITE_ACCEPT, INIT_FAILED); + failure_case (GROUP_INVITE_ACCEPT, PASSWORD); + failure_case (GROUP_INVITE_ACCEPT, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSetPassword", Group_Set_Password) +{ + switch (error) + { + success_case (GROUP_SET_PASSWORD); + failure_case (GROUP_SET_PASSWORD, DISCONNECTED); + failure_case (GROUP_SET_PASSWORD, FAIL_SEND); + failure_case (GROUP_SET_PASSWORD, GROUP_NOT_FOUND); + failure_case (GROUP_SET_PASSWORD, MALLOC); + failure_case (GROUP_SET_PASSWORD, PERMISSIONS); + failure_case (GROUP_SET_PASSWORD, TOO_LONG); + } + return unhandled (); +} + +HANDLE ("GroupSetTopicLock", Group_Set_Topic_Lock) +{ + switch (error) + { + success_case (GROUP_SET_TOPIC_LOCK); + failure_case (GROUP_SET_TOPIC_LOCK, DISCONNECTED); + failure_case (GROUP_SET_TOPIC_LOCK, FAIL_SEND); + failure_case (GROUP_SET_TOPIC_LOCK, FAIL_SET); + failure_case (GROUP_SET_TOPIC_LOCK, GROUP_NOT_FOUND); + failure_case (GROUP_SET_TOPIC_LOCK, INVALID); + failure_case (GROUP_SET_TOPIC_LOCK, PERMISSIONS); + } + return unhandled (); +} + +HANDLE ("GroupSetVoiceState", Group_Set_Voice_State) +{ + switch (error) + { + success_case (GROUP_SET_VOICE_STATE); + failure_case (GROUP_SET_VOICE_STATE, DISCONNECTED); + failure_case (GROUP_SET_VOICE_STATE, FAIL_SEND); + failure_case (GROUP_SET_VOICE_STATE, FAIL_SET); + failure_case (GROUP_SET_VOICE_STATE, GROUP_NOT_FOUND); + failure_case (GROUP_SET_VOICE_STATE, PERMISSIONS); + } + return unhandled (); +} + +HANDLE ("GroupSetPrivacyState", Group_Set_Privacy_State) +{ + switch (error) + { + success_case (GROUP_SET_PRIVACY_STATE); + failure_case (GROUP_SET_PRIVACY_STATE, DISCONNECTED); + failure_case (GROUP_SET_PRIVACY_STATE, FAIL_SEND); + failure_case (GROUP_SET_PRIVACY_STATE, FAIL_SET); + failure_case (GROUP_SET_PRIVACY_STATE, GROUP_NOT_FOUND); + failure_case (GROUP_SET_PRIVACY_STATE, PERMISSIONS); + } + return unhandled (); +} + +HANDLE ("GroupSetPeerLimit", Group_Set_Peer_Limit) +{ + switch (error) + { + success_case (GROUP_SET_PEER_LIMIT); + failure_case (GROUP_SET_PEER_LIMIT, DISCONNECTED); + failure_case (GROUP_SET_PEER_LIMIT, FAIL_SEND); + failure_case (GROUP_SET_PEER_LIMIT, FAIL_SET); + failure_case (GROUP_SET_PEER_LIMIT, GROUP_NOT_FOUND); + failure_case (GROUP_SET_PEER_LIMIT, PERMISSIONS); + } + return unhandled (); +} + +HANDLE ("GroupSetIgnore", Group_Set_Ignore) +{ + switch (error) + { + success_case (GROUP_SET_IGNORE); + failure_case (GROUP_SET_IGNORE, GROUP_NOT_FOUND); + failure_case (GROUP_SET_IGNORE, PEER_NOT_FOUND); + failure_case (GROUP_SET_IGNORE, SELF); + } + return unhandled (); +} + +HANDLE ("GroupSetRole", Group_Set_Role) +{ + switch (error) + { + success_case (GROUP_SET_ROLE); + failure_case (GROUP_SET_ROLE, ASSIGNMENT); + failure_case (GROUP_SET_ROLE, FAIL_ACTION); + failure_case (GROUP_SET_ROLE, GROUP_NOT_FOUND); + failure_case (GROUP_SET_ROLE, PEER_NOT_FOUND); + failure_case (GROUP_SET_ROLE, PERMISSIONS); + failure_case (GROUP_SET_ROLE, SELF); + } + return unhandled (); +} + +HANDLE ("GroupKickPeer", Group_Kick_Peer) +{ + switch (error) + { + success_case (GROUP_KICK_PEER); + failure_case (GROUP_KICK_PEER, FAIL_ACTION); + failure_case (GROUP_KICK_PEER, FAIL_SEND); + failure_case (GROUP_KICK_PEER, GROUP_NOT_FOUND); + failure_case (GROUP_KICK_PEER, PEER_NOT_FOUND); + failure_case (GROUP_KICK_PEER, PERMISSIONS); + failure_case (GROUP_KICK_PEER, SELF); + } + return unhandled (); +} diff --git a/lib/src/jvmMain/cpp/ToxCore/generated/im_tox_tox4j_impl_jni_ToxCoreJni.h b/lib/src/jvmMain/cpp/ToxCore/generated/im_tox_tox4j_impl_jni_ToxCoreJni.h index 0cd22ade2..49a941810 100644 --- a/lib/src/jvmMain/cpp/ToxCore/generated/im_tox_tox4j_impl_jni_ToxCoreJni.h +++ b/lib/src/jvmMain/cpp/ToxCore/generated/im_tox_tox4j_impl_jni_ToxCoreJni.h @@ -250,10 +250,10 @@ JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxSelfSetTyping /* * Class: im_tox_tox4j_impl_jni_ToxCoreJni * Method: toxFriendSendMessage - * Signature: (IIII[B)I + * Signature: (III[B)I */ JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendSendMessage - (JNIEnv *, jclass, jint, jint, jint, jint, jbyteArray); + (JNIEnv *, jclass, jint, jint, jint, jbyteArray); /* * Class: im_tox_tox4j_impl_jni_ToxCoreJni @@ -311,6 +311,510 @@ JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendSendLossyP JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxFriendSendLosslessPacket (JNIEnv *, jclass, jint, jint, jbyteArray); +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceNew + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceNew + (JNIEnv *, jclass, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceDelete + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceDelete + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerCount + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerCount + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerGetName + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerGetName + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerGetPublicKey + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerGetPublicKey + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferencePeerNumberIsOurs + * Signature: (III)Z + */ +JNIEXPORT jboolean JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferencePeerNumberIsOurs + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerCount + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerCount + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerGetName + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerGetName + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerGetPublicKey + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerGetPublicKey + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceOfflinePeerGetLastActive + * Signature: (III)J + */ +JNIEXPORT jlong JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceOfflinePeerGetLastActive + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceSetMaxOffline + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceSetMaxOffline + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceInvite + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceInvite + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceJoin + * Signature: (II[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceJoin + (JNIEnv *, jclass, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceSendMessage + * Signature: (III[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceSendMessage + (JNIEnv *, jclass, jint, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetTitle + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetTitle + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceSetTitle + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceSetTitle + (JNIEnv *, jclass, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetChatlist + * Signature: (I)[I + */ +JNIEXPORT jintArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetChatlist + (JNIEnv *, jclass, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetType + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetType + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetId + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetId + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceById + * Signature: (I[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceById + (JNIEnv *, jclass, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceGetUid + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceGetUid + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxConferenceByUid + * Signature: (I[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxConferenceByUid + (JNIEnv *, jclass, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupNew + * Signature: (II[B[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupNew + (JNIEnv *, jclass, jint, jint, jbyteArray, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupJoin + * Signature: (I[B[B[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupJoin + (JNIEnv *, jclass, jint, jbyteArray, jbyteArray, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupIsConnected + * Signature: (II)Z + */ +JNIEXPORT jboolean JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupIsConnected + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupDisconnect + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupDisconnect + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupReconnect + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupReconnect + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupLeave + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupLeave + (JNIEnv *, jclass, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfSetName + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfSetName + (JNIEnv *, jclass, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetName + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetName + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfSetStatus + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfSetStatus + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetStatus + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetStatus + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetRole + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetRole + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetPeerId + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetPeerId + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSelfGetPublicKey + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSelfGetPublicKey + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetName + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetName + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetStatus + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetStatus + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetRole + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetRole + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetConnectionStatus + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetConnectionStatus + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupPeerGetPublicKey + * Signature: (III)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupPeerGetPublicKey + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetTopic + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetTopic + (JNIEnv *, jclass, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetTopic + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetTopic + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetName + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetName + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetChatId + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetChatId + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetPrivacyState + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetPrivacyState + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetVoiceState + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetVoiceState + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetTopicLock + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetTopicLock + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetPeerLimit + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetPeerLimit + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupGetPassword + * Signature: (II)[B + */ +JNIEXPORT jbyteArray JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupGetPassword + (JNIEnv *, jclass, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendMessage + * Signature: (III[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendMessage + (JNIEnv *, jclass, jint, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendPrivateMessage + * Signature: (IIII[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendPrivateMessage + (JNIEnv *, jclass, jint, jint, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendCustomPacket + * Signature: (IIZ[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendCustomPacket + (JNIEnv *, jclass, jint, jint, jboolean, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSendCustomPrivatePacket + * Signature: (IIIZ[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSendCustomPrivatePacket + (JNIEnv *, jclass, jint, jint, jint, jboolean, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupInviteFriend + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupInviteFriend + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupInviteAccept + * Signature: (II[B[B[B)I + */ +JNIEXPORT jint JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupInviteAccept + (JNIEnv *, jclass, jint, jint, jbyteArray, jbyteArray, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetPassword + * Signature: (II[B)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetPassword + (JNIEnv *, jclass, jint, jint, jbyteArray); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetTopicLock + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetTopicLock + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetVoiceState + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetVoiceState + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetPrivacyState + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetPrivacyState + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetPeerLimit + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetPeerLimit + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetIgnore + * Signature: (IIIZ)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetIgnore + (JNIEnv *, jclass, jint, jint, jint, jboolean); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupSetRole + * Signature: (IIII)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupSetRole + (JNIEnv *, jclass, jint, jint, jint, jint); + +/* + * Class: im_tox_tox4j_impl_jni_ToxCoreJni + * Method: toxGroupKickPeer + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_im_tox_tox4j_impl_jni_ToxCoreJni_toxGroupKickPeer + (JNIEnv *, jclass, jint, jint, jint); + #ifdef __cplusplus } #endif diff --git a/lib/src/jvmMain/cpp/ToxCore/interaction.cpp b/lib/src/jvmMain/cpp/ToxCore/interaction.cpp deleted file mode 100644 index ee0757b90..000000000 --- a/lib/src/jvmMain/cpp/ToxCore/interaction.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "ToxCore.h" - -using namespace core; - - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxSelfSetTyping - * Signature: (IIZ)V - */ -TOX_METHOD (void, SelfSetTyping, - jint instanceNumber, jint friendNumber, jboolean isTyping) -{ - return instances.with_instance_ign (env, instanceNumber, - tox_self_set_typing, friendNumber, isTyping - ); -} - - -/* - * Class: im_tox_tox4j_impl_ToxCoreJni - * Method: toxFriendSendMessage - * Signature: (IIII[B)I - */ -TOX_METHOD (jint, FriendSendMessage, - jint instanceNumber, jint friendNumber, jint messageType, jint timeDelta, jbyteArray message) -{ - auto message_array = fromJavaArray (env, message); - - return instances.with_instance_err (env, instanceNumber, - identity, - tox_friend_send_message, friendNumber, Enum::valueOf (env, messageType), message_array.data (), message_array.size () - ); -} diff --git a/lib/src/jvmMain/cpp/ToxCore/lifecycle.cpp b/lib/src/jvmMain/cpp/ToxCore/lifecycle.cpp index d6e8727ec..ee4a5308f 100644 --- a/lib/src/jvmMain/cpp/ToxCore/lifecycle.cpp +++ b/lib/src/jvmMain/cpp/ToxCore/lifecycle.cpp @@ -7,7 +7,7 @@ using namespace core; template static void -set_connection_status (Message &msg, TOX_CONNECTION connection_status) +set_connection_status (Message *msg, TOX_CONNECTION connection_status) { using proto::Connection; switch (connection_status) @@ -24,15 +24,16 @@ set_connection_status (Message &msg, TOX_CONNECTION connection_status) } } + static void -tox4j_self_connection_status_cb (TOX_CONNECTION connection_status, Events *events) +tox4j_self_connection_status_cb (Tox_Connection connection_status, Events *events) { auto msg = events->add_self_connection_status (); set_connection_status (msg, connection_status); } static void -tox4j_friend_name_cb (uint32_t friend_number, uint8_t const *name, size_t length, Events *events) +tox4j_friend_name_cb (Tox_Friend_Number friend_number, uint8_t const *name, size_t length, Events *events) { auto msg = events->add_friend_name (); msg->set_friend_number (friend_number); @@ -40,36 +41,39 @@ tox4j_friend_name_cb (uint32_t friend_number, uint8_t const *name, size_t length } static void -tox4j_friend_status_message_cb (uint32_t friend_number, uint8_t const *message, size_t length, Events *events) +tox4j_friend_status_message_cb (Tox_Friend_Number friend_number, uint8_t const *message, size_t length, Events *events) { auto msg = events->add_friend_status_message (); msg->set_friend_number (friend_number); msg->set_message (message, length); } -static void -tox4j_friend_status_cb (uint32_t friend_number, TOX_USER_STATUS status, Events *events) -{ - auto msg = events->add_friend_status (); - msg->set_friend_number (friend_number); - +template +static void set_user_status(Message *msg, Tox_User_Status status) { using proto::UserStatus; - switch (status) - { + switch (status) { case TOX_USER_STATUS_NONE: - msg->set_status (UserStatus::NONE); + msg->set_status(UserStatus::NONE); break; case TOX_USER_STATUS_AWAY: - msg->set_status (UserStatus::AWAY); + msg->set_status(UserStatus::AWAY); break; case TOX_USER_STATUS_BUSY: - msg->set_status (UserStatus::BUSY); + msg->set_status(UserStatus::BUSY); break; - } + } +} + +static void +tox4j_friend_status_cb (Tox_Friend_Number friend_number, Tox_User_Status status, Events *events) +{ + auto msg = events->add_friend_status (); + msg->set_friend_number (friend_number); + set_user_status(msg, status); } static void -tox4j_friend_connection_status_cb (uint32_t friend_number, TOX_CONNECTION connection_status, Events *events) +tox4j_friend_connection_status_cb (Tox_Friend_Number friend_number, Tox_Connection connection_status, Events *events) { auto msg = events->add_friend_connection_status (); msg->set_friend_number (friend_number); @@ -77,7 +81,7 @@ tox4j_friend_connection_status_cb (uint32_t friend_number, TOX_CONNECTION connec } static void -tox4j_friend_typing_cb (uint32_t friend_number, bool is_typing, Events *events) +tox4j_friend_typing_cb (Tox_Friend_Number friend_number, bool is_typing, Events *events) { auto msg = events->add_friend_typing (); msg->set_friend_number (friend_number); @@ -85,7 +89,7 @@ tox4j_friend_typing_cb (uint32_t friend_number, bool is_typing, Events *events) } static void -tox4j_friend_read_receipt_cb (uint32_t friend_number, uint32_t message_id, Events *events) +tox4j_friend_read_receipt_cb (Tox_Friend_Number friend_number, Tox_Friend_Message_Id message_id, Events *events) { auto msg = events->add_friend_read_receipt (); msg->set_friend_number (friend_number); @@ -93,37 +97,35 @@ tox4j_friend_read_receipt_cb (uint32_t friend_number, uint32_t message_id, Event } static void -tox4j_friend_request_cb (uint8_t const *public_key, /*uint32_t time_delta, */ uint8_t const *message, size_t length, Events *events) +tox4j_friend_request_cb (uint8_t const *public_key, uint8_t const *message, size_t length, Events *events) { auto msg = events->add_friend_request (); msg->set_public_key (public_key, TOX_PUBLIC_KEY_SIZE); - msg->set_time_delta (0); msg->set_message (message, length); } -static void -tox4j_friend_message_cb (uint32_t friend_number, TOX_MESSAGE_TYPE type, /*uint32_t time_delta, */ uint8_t const *message, size_t length, Events *events) -{ - auto msg = events->add_friend_message (); - msg->set_friend_number (friend_number); - +template +static void set_message_type(Message *msg, Tox_Message_Type type) { using proto::MessageType; - switch (type) - { + switch (type) { case TOX_MESSAGE_TYPE_NORMAL: - msg->set_type (MessageType::NORMAL); + msg->set_message_type(MessageType::NORMAL); break; case TOX_MESSAGE_TYPE_ACTION: - msg->set_type (MessageType::ACTION); + msg->set_message_type(MessageType::ACTION); break; - } + } +} - msg->set_time_delta (0); - msg->set_message (message, length); +static void tox4j_friend_message_cb(Tox_Friend_Number friend_number, Tox_Message_Type type, uint8_t const* message, size_t length, Events* events) { + auto msg = events->add_friend_message(); + msg->set_friend_number(friend_number); + set_message_type(msg, type); + msg->set_message(message, length); } static void -tox4j_file_recv_control_cb (uint32_t friend_number, uint32_t file_number, TOX_FILE_CONTROL control, Events *events) +tox4j_file_recv_control_cb (Tox_Friend_Number friend_number, Tox_File_Number file_number, Tox_File_Control control, Events *events) { auto msg = events->add_file_recv_control (); msg->set_friend_number (friend_number); @@ -145,7 +147,7 @@ tox4j_file_recv_control_cb (uint32_t friend_number, uint32_t file_number, TOX_FI } static void -tox4j_file_chunk_request_cb (uint32_t friend_number, uint32_t file_number, uint64_t position, size_t length, Events *events) +tox4j_file_chunk_request_cb (Tox_Friend_Number friend_number, Tox_File_Number file_number, uint64_t position, size_t length, Events *events) { auto msg = events->add_file_chunk_request (); msg->set_friend_number (friend_number); @@ -155,7 +157,7 @@ tox4j_file_chunk_request_cb (uint32_t friend_number, uint32_t file_number, uint6 } static void -tox4j_file_recv_cb (uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t file_size, uint8_t const *filename, size_t filename_length, Events *events) +tox4j_file_recv_cb (Tox_Friend_Number friend_number, Tox_File_Number file_number, uint32_t kind, uint64_t file_size, uint8_t const *filename, size_t filename_length, Events *events) { auto msg = events->add_file_recv (); msg->set_friend_number (friend_number); @@ -166,7 +168,7 @@ tox4j_file_recv_cb (uint32_t friend_number, uint32_t file_number, uint32_t kind, } static void -tox4j_file_recv_chunk_cb (uint32_t friend_number, uint32_t file_number, uint64_t position, uint8_t const *data, size_t length, Events *events) +tox4j_file_recv_chunk_cb (Tox_Friend_Number friend_number, Tox_File_Number file_number, uint64_t position, uint8_t const *data, size_t length, Events *events) { auto msg = events->add_file_recv_chunk (); msg->set_friend_number (friend_number); @@ -176,7 +178,7 @@ tox4j_file_recv_chunk_cb (uint32_t friend_number, uint32_t file_number, uint64_t } static void -tox4j_friend_lossy_packet_cb (uint32_t friend_number, uint8_t const *data, size_t length, Events *events) +tox4j_friend_lossy_packet_cb (Tox_Friend_Number friend_number, uint8_t const *data, size_t length, Events *events) { auto msg = events->add_friend_lossy_packet (); msg->set_friend_number (friend_number); @@ -184,13 +186,320 @@ tox4j_friend_lossy_packet_cb (uint32_t friend_number, uint8_t const *data, size_ } static void -tox4j_friend_lossless_packet_cb (uint32_t friend_number, uint8_t const *data, size_t length, Events *events) +tox4j_friend_lossless_packet_cb (Tox_Friend_Number friend_number, uint8_t const *data, size_t length, Events *events) { auto msg = events->add_friend_lossless_packet (); msg->set_friend_number (friend_number); msg->set_data (data, length); } +static void +tox4j_conference_invite_cb (Tox_Friend_Number friend_number, Tox_Conference_Type type, uint8_t const *cookie, size_t length, Events *events) +{ + auto msg = events->add_conference_invite (); + msg->set_friend_number (friend_number); + + using proto::ConferenceType; + switch (type) + { + case TOX_CONFERENCE_TYPE_TEXT: + msg->set_type (ConferenceType::TEXT); + break; + case TOX_CONFERENCE_TYPE_AV: + msg->set_type (ConferenceType::AV); + break; + } + + msg->set_cookie (cookie, length); +} + +static void +tox4j_conference_connected_cb (Tox_Conference_Number conference_number, Events *events) +{ + auto msg = events->add_conference_connected (); + msg->set_conference_number (conference_number); +} + +static void +tox4j_conference_message_cb (Tox_Conference_Number conference_number, Tox_Conference_Peer_Number peer_number, Tox_Message_Type type, uint8_t const *message, size_t length, Events *events) +{ + auto msg = events->add_conference_message (); + msg->set_conference_number (conference_number); + msg->set_peer_number (peer_number); + set_message_type (msg, type); + msg->set_message (message, length); +} + +static void +tox4j_conference_title_cb (Tox_Conference_Number conference_number, Tox_Conference_Peer_Number peer_number, uint8_t const *title, size_t length, Events *events) +{ + auto msg = events->add_conference_title (); + msg->set_conference_number (conference_number); + msg->set_peer_number (peer_number); + msg->set_title (title, length); +} + +static void +tox4j_conference_peer_name_cb (Tox_Conference_Number conference_number, Tox_Conference_Peer_Number peer_number, uint8_t const *name, size_t length, Events *events) +{ + auto msg = events->add_conference_peer_name (); + msg->set_conference_number (conference_number); + msg->set_peer_number (peer_number); + msg->set_name (name, length); +} + +static void +tox4j_conference_peer_list_changed_cb (Tox_Conference_Number conference_number, Events *events) +{ + auto msg = events->add_conference_peer_list_changed (); + msg->set_conference_number (conference_number); +} + +static void +tox4j_group_peer_name_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, uint8_t const *name, size_t name_length, Events *events) +{ + auto msg = events->add_group_peer_name (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + msg->set_name (name, name_length); +} + +static void +tox4j_group_peer_status_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_User_Status status, Events *events) +{ + auto msg = events->add_group_peer_status (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + set_user_status(msg, status); +} + +static void +tox4j_group_topic_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, uint8_t const *topic, size_t topic_length, Events *events) +{ + auto msg = events->add_group_topic (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + msg->set_topic (topic, topic_length); +} + +static void +tox4j_group_privacy_state_cb (Tox_Group_Number group_number, Tox_Group_Privacy_State privacy_state, Events *events) +{ + auto msg = events->add_group_privacy_state (); + msg->set_group_number (group_number); + + using proto::GroupPrivacyState; + switch (privacy_state) + { + case TOX_GROUP_PRIVACY_STATE_PUBLIC: + msg->set_privacy_state (GroupPrivacyState::PUBLIC); + break; + case TOX_GROUP_PRIVACY_STATE_PRIVATE: + msg->set_privacy_state (GroupPrivacyState::PRIVATE); + break; + } +} + +static void +tox4j_group_voice_state_cb (uint32_t group_number, Tox_Group_Voice_State voice_state, Events *events) +{ + auto msg = events->add_group_voice_state (); + msg->set_group_number (group_number); + + using proto::GroupVoiceState; + switch (voice_state) + { + case TOX_GROUP_VOICE_STATE_ALL: + msg->set_voice_state (GroupVoiceState::ALL); + break; + case TOX_GROUP_VOICE_STATE_MODERATOR: + msg->set_voice_state (GroupVoiceState::MODERATOR); + break; + case TOX_GROUP_VOICE_STATE_FOUNDER: + msg->set_voice_state (GroupVoiceState::FOUNDER); + break; + } +} + +static void +tox4j_group_topic_lock_cb (uint32_t group_number, Tox_Group_Topic_Lock topic_lock, Events *events) +{ + auto msg = events->add_group_topic_lock (); + msg->set_group_number (group_number); + + using proto::GroupTopicLock; + switch (topic_lock) + { + case TOX_GROUP_TOPIC_LOCK_ENABLED: + msg->set_topic_lock (GroupTopicLock::ENABLED); + break; + case TOX_GROUP_TOPIC_LOCK_DISABLED: + msg->set_topic_lock (GroupTopicLock::DISABLED); + break; + } +} + +static void +tox4j_group_peer_limit_cb (uint32_t group_number, uint32_t peer_limit, Events *events) +{ + auto msg = events->add_group_peer_limit (); + msg->set_group_number (group_number); + msg->set_peer_limit (peer_limit); +} + +static void +tox4j_group_password_cb (uint32_t group_number, uint8_t const *password, size_t password_length, Events *events) +{ + auto msg = events->add_group_password (); + msg->set_group_number (group_number); + msg->set_password (password, password_length); +} + +static void +tox4j_group_message_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type, uint8_t const *message, size_t message_length, Tox_Group_Message_Id message_id, Events *events) +{ + auto msg = events->add_group_message (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + set_message_type (msg, message_type); + msg->set_message (message, message_length); + msg->set_message_id (message_id); +} + +static void +tox4j_group_private_message_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type, uint8_t const *message, size_t message_length, Tox_Group_Message_Id message_id, Events *events) +{ + auto msg = events->add_group_private_message (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + set_message_type (msg, message_type); + msg->set_message (message, message_length); + msg->set_message_id (message_id); +} + +static void +tox4j_group_custom_packet_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, uint8_t const *data, size_t data_length, Events *events) +{ + auto msg = events->add_group_custom_packet (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + msg->set_data (data, data_length); +} + +static void +tox4j_group_custom_private_packet_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, uint8_t const *data, size_t data_length, Events *events) +{ + auto msg = events->add_group_custom_private_packet (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + msg->set_data (data, data_length); +} + +static void +tox4j_group_invite_cb (Tox_Friend_Number friend_number, uint8_t const *invite_data, size_t invite_data_length, uint8_t const *group_name, size_t group_name_length, Events *events) +{ + auto msg = events->add_group_invite (); + msg->set_friend_number (friend_number); + msg->set_invite_data (invite_data, invite_data_length); + msg->set_group_name (group_name, group_name_length); +} + +static void +tox4j_group_peer_join_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Events *events) +{ + auto msg = events->add_group_peer_join (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); +} + +static void +tox4j_group_peer_exit_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Group_Exit_Type exit_type, uint8_t const *name, size_t name_length, uint8_t const *part_message, size_t part_message_length, Events *events) +{ + auto msg = events->add_group_peer_exit (); + msg->set_group_number (group_number); + msg->set_peer_id (peer_id); + + using proto::GroupExitType; + switch (exit_type) + { + case TOX_GROUP_EXIT_TYPE_QUIT: + msg->set_exit_type (GroupExitType::QUIT); + break; + case TOX_GROUP_EXIT_TYPE_TIMEOUT: + msg->set_exit_type (GroupExitType::TIMEOUT); + break; + case TOX_GROUP_EXIT_TYPE_DISCONNECTED: + msg->set_exit_type (GroupExitType::DISCONNECTED); + break; + case TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED: + msg->set_exit_type (GroupExitType::SELF_DISCONNECTED); + break; + case TOX_GROUP_EXIT_TYPE_KICK: + msg->set_exit_type (GroupExitType::KICK); + break; + case TOX_GROUP_EXIT_TYPE_SYNC_ERROR: + msg->set_exit_type (GroupExitType::SYNC_ERROR); + break; + } + + msg->set_name (name, name_length); + msg->set_part_message (part_message, part_message_length); +} + +static void +tox4j_group_self_join_cb (Tox_Group_Number group_number, Events *events) +{ + auto msg = events->add_group_self_join (); + msg->set_group_number (group_number); +} + +static void +tox4j_group_join_fail_cb (Tox_Group_Number group_number, Tox_Group_Join_Fail fail_type, Events *events) +{ + auto msg = events->add_group_join_fail (); + msg->set_group_number (group_number); + + using proto::GroupJoinFail; + switch (fail_type) + { + case TOX_GROUP_JOIN_FAIL_PEER_LIMIT: + msg->set_fail_type (GroupJoinFail::PEER_LIMIT); + break; + case TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD: + msg->set_fail_type (GroupJoinFail::INVALID_PASSWORD); + break; + case TOX_GROUP_JOIN_FAIL_UNKNOWN: + msg->set_fail_type (GroupJoinFail::UNKNOWN); + break; + } +} + +static void +tox4j_group_moderation_cb (Tox_Group_Number group_number, Tox_Group_Peer_Number source_peer_id, Tox_Group_Peer_Number target_peer_id, Tox_Group_Mod_Event mod_type, Events *events) +{ + auto msg = events->add_group_moderation (); + msg->set_group_number (group_number); + msg->set_source_peer_id (source_peer_id); + msg->set_target_peer_id (target_peer_id); + + using proto::GroupModEvent; + switch (mod_type) + { + case TOX_GROUP_MOD_EVENT_KICK: + msg->set_mod_type (GroupModEvent::KICK); + break; + case TOX_GROUP_MOD_EVENT_OBSERVER: + msg->set_mod_type (GroupModEvent::OBSERVER); + break; + case TOX_GROUP_MOD_EVENT_USER: + msg->set_mod_type (GroupModEvent::USER); + break; + case TOX_GROUP_MOD_EVENT_MODERATOR: + msg->set_mod_type (GroupModEvent::MODERATOR); + break; + } +} + static auto tox_options_new_unique () @@ -225,12 +534,6 @@ TOX_METHOD (jint, New, jint startPort, jint endPort, jint tcpPort, jint saveDataType, jbyteArray saveData) { -#if 0 - scope_guard { - [&]{ printf ("creating new instance"); }, - }; -#endif - auto opts = tox_options_new_unique (); if (!opts) { @@ -255,8 +558,9 @@ TOX_METHOD (jint, New, tox4j_assert (port >= 0); tox4j_assert (port <= 65535); }; - if (tox_options_get_proxy_type (opts.get ()) != TOX_PROXY_TYPE_NONE) + if (tox_options_get_proxy_type (opts.get ()) != TOX_PROXY_TYPE_NONE) { assert_valid_uint16 (proxyPort); + } assert_valid_uint16 (startPort); assert_valid_uint16 (endPort); assert_valid_uint16 (tcpPort); diff --git a/lib/src/jvmMain/cpp/ToxCrypto/ToxCrypto.h b/lib/src/jvmMain/cpp/ToxCrypto/ToxCrypto.h index d46a4cd1a..827850643 100644 --- a/lib/src/jvmMain/cpp/ToxCrypto/ToxCrypto.h +++ b/lib/src/jvmMain/cpp/ToxCrypto/ToxCrypto.h @@ -8,6 +8,7 @@ #include #define SUBSYSTEM TOX +#define STRUCT Tox #define CLASS ToxCrypto #define PREFIX tox diff --git a/lib/src/jvmMain/cpp/ToxCrypto/generated/errors.cpp b/lib/src/jvmMain/cpp/ToxCrypto/generated/errors.cpp index b5341a7fb..e5be74353 100644 --- a/lib/src/jvmMain/cpp/ToxCrypto/generated/errors.cpp +++ b/lib/src/jvmMain/cpp/ToxCrypto/generated/errors.cpp @@ -1,6 +1,6 @@ #include "../ToxCrypto.h" -HANDLE ("Decryption", DECRYPTION) +HANDLE ("Decryption", Decryption) { switch (error) { @@ -14,7 +14,7 @@ HANDLE ("Decryption", DECRYPTION) return unhandled (); } -HANDLE ("Encryption", ENCRYPTION) +HANDLE ("Encryption", Encryption) { switch (error) { @@ -26,7 +26,7 @@ HANDLE ("Encryption", ENCRYPTION) return unhandled (); } -HANDLE ("GetSalt", GET_SALT) +HANDLE ("GetSalt", Get_Salt) { switch (error) { @@ -37,7 +37,7 @@ HANDLE ("GetSalt", GET_SALT) return unhandled (); } -HANDLE ("KeyDerivation", KEY_DERIVATION) +HANDLE ("KeyDerivation", Key_Derivation) { switch (error) { diff --git a/lib/src/jvmMain/cpp/tox/core.h b/lib/src/jvmMain/cpp/tox/core.h index 914e0f43d..847c16d7f 100644 --- a/lib/src/jvmMain/cpp/tox/core.h +++ b/lib/src/jvmMain/cpp/tox/core.h @@ -16,31 +16,12 @@ namespace tox typedef std::unique_ptr core_ptr; -#define COMPAT_CB(CB) \ +#define CALLBACK(CB) \ inline void tox_callback_##CB(Tox *tox, tox_##CB##_cb *callback, void *) \ { \ ::tox_callback_##CB(tox, callback); \ - } - - COMPAT_CB (self_connection_status) - COMPAT_CB (friend_status_message) - COMPAT_CB (friend_name) - COMPAT_CB (friend_request) - COMPAT_CB (friend_typing) - COMPAT_CB (file_chunk_request) - COMPAT_CB (file_recv) - COMPAT_CB (file_recv_chunk) - COMPAT_CB (file_recv_control) - COMPAT_CB (friend_connection_status) - COMPAT_CB (friend_lossless_packet) - COMPAT_CB (friend_lossy_packet) - COMPAT_CB (friend_message) - COMPAT_CB (friend_read_receipt) - COMPAT_CB (friend_status) - -#undef COMPAT_CB - -#define CALLBACK(NAME) using callback_##NAME = detail::cb; + } \ + using callback_##CB = detail::cb; #include "generated/core.h" #undef CALLBACK } diff --git a/lib/src/jvmMain/cpp/tox/generated/core.h b/lib/src/jvmMain/cpp/tox/generated/core.h index 90e04cbf0..c05917ae6 100644 --- a/lib/src/jvmMain/cpp/tox/generated/core.h +++ b/lib/src/jvmMain/cpp/tox/generated/core.h @@ -1,30 +1,39 @@ -// im.tox.tox4j.core.callbacks.FileChunkRequestCallback#fileChunkRequest +CALLBACK (conference_connected) +CALLBACK (conference_invite) +CALLBACK (conference_message) +CALLBACK (conference_peer_list_changed) +CALLBACK (conference_peer_name) +CALLBACK (conference_title) CALLBACK (file_chunk_request) -// im.tox.tox4j.core.callbacks.FileRecvCallback#fileRecv CALLBACK (file_recv) -// im.tox.tox4j.core.callbacks.FileRecvChunkCallback#fileRecvChunk CALLBACK (file_recv_chunk) -// im.tox.tox4j.core.callbacks.FileRecvControlCallback#fileRecvControl CALLBACK (file_recv_control) -// im.tox.tox4j.core.callbacks.FriendConnectionStatusCallback#friendConnectionStatus CALLBACK (friend_connection_status) -// im.tox.tox4j.core.callbacks.FriendLosslessPacketCallback#friendLosslessPacket CALLBACK (friend_lossless_packet) -// im.tox.tox4j.core.callbacks.FriendLossyPacketCallback#friendLossyPacket CALLBACK (friend_lossy_packet) -// im.tox.tox4j.core.callbacks.FriendMessageCallback#friendMessage CALLBACK (friend_message) -// im.tox.tox4j.core.callbacks.FriendNameCallback#friendName CALLBACK (friend_name) -// im.tox.tox4j.core.callbacks.FriendReadReceiptCallback#friendReadReceipt CALLBACK (friend_read_receipt) -// im.tox.tox4j.core.callbacks.FriendRequestCallback#friendRequest CALLBACK (friend_request) -// im.tox.tox4j.core.callbacks.FriendStatusCallback#friendStatus CALLBACK (friend_status) -// im.tox.tox4j.core.callbacks.FriendStatusMessageCallback#friendStatusMessage CALLBACK (friend_status_message) -// im.tox.tox4j.core.callbacks.FriendTypingCallback#friendTyping CALLBACK (friend_typing) -// im.tox.tox4j.core.callbacks.SelfConnectionStatusCallback#selfConnectionStatus +CALLBACK (group_custom_packet) +CALLBACK (group_custom_private_packet) +CALLBACK (group_invite) +CALLBACK (group_join_fail) +CALLBACK (group_message) +CALLBACK (group_moderation) +CALLBACK (group_password) +CALLBACK (group_peer_exit) +CALLBACK (group_peer_join) +CALLBACK (group_peer_limit) +CALLBACK (group_peer_name) +CALLBACK (group_peer_status) +CALLBACK (group_privacy_state) +CALLBACK (group_private_message) +CALLBACK (group_self_join) +CALLBACK (group_topic) +CALLBACK (group_topic_lock) +CALLBACK (group_voice_state) CALLBACK (self_connection_status) diff --git a/lib/src/jvmMain/cpp/tox4j/ToxInstances.h b/lib/src/jvmMain/cpp/tox4j/ToxInstances.h index 064a7093d..6f13cc4a1 100644 --- a/lib/src/jvmMain/cpp/tox4j/ToxInstances.h +++ b/lib/src/jvmMain/cpp/tox4j/ToxInstances.h @@ -134,25 +134,28 @@ struct error_type_of +#define ERROR_ENUM(METHOD) \ + PP_CAT(STRUCT, _Err_##METHOD) + #define ERROR_CODE(METHOD) \ - PP_CAT (SUBSYSTEM, _ERR_##METHOD) + PP_CAT(SUBSYSTEM, _ERR_##METHOD) #define success_case(METHOD) \ - case PP_CAT (ERROR_CODE (METHOD), _OK): \ + case PP_CAT(ERROR_CODE(METHOD), _OK): \ return success() #define failure_case(METHOD, ERROR) \ - case PP_CAT (ERROR_CODE (METHOD), _##ERROR): \ + case PP_CAT(ERROR_CODE(METHOD), _##ERROR): \ return failure (#ERROR) #define HANDLE(NAME, METHOD) \ template<> \ -char const *method_name() { return NAME; } \ +char const *method_name() { return NAME; } \ \ template<> \ ErrorHandling \ -handle_error_enum (ERROR_CODE (METHOD) error) +handle_error_enum(ERROR_ENUM(METHOD) error) /** diff --git a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxAvImpl.kt b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxAvImpl.kt index 24ffaef2b..108c86f25 100644 --- a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxAvImpl.kt +++ b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxAvImpl.kt @@ -112,5 +112,6 @@ final class ToxAvImpl(private val tox: ToxCoreImpl) : ToxAv { y: ByteArray, u: ByteArray, v: ByteArray, - ): Unit = ToxAvJni.toxavVideoSendFrame(instanceNumber, friendNumber.value, width, height, y, u, v) + ): Unit = + ToxAvJni.toxavVideoSendFrame(instanceNumber, friendNumber.value, width, height, y, u, v) } diff --git a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreEventDispatch.kt b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreEventDispatch.kt index b8c56e354..fa41128ea 100644 --- a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreEventDispatch.kt +++ b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreEventDispatch.kt @@ -1,19 +1,81 @@ package im.tox.tox4j.impl.jni +import im.tox.tox4j.core.callbacks.ConferenceConnectedCallback +import im.tox.tox4j.core.callbacks.ConferenceInviteCallback +import im.tox.tox4j.core.callbacks.ConferenceMessageCallback +import im.tox.tox4j.core.callbacks.ConferencePeerListChangedCallback +import im.tox.tox4j.core.callbacks.ConferencePeerNameCallback +import im.tox.tox4j.core.callbacks.ConferenceTitleCallback +import im.tox.tox4j.core.callbacks.FileChunkRequestCallback +import im.tox.tox4j.core.callbacks.FileRecvCallback +import im.tox.tox4j.core.callbacks.FileRecvChunkCallback +import im.tox.tox4j.core.callbacks.FileRecvControlCallback +import im.tox.tox4j.core.callbacks.FriendConnectionStatusCallback +import im.tox.tox4j.core.callbacks.FriendLosslessPacketCallback +import im.tox.tox4j.core.callbacks.FriendLossyPacketCallback +import im.tox.tox4j.core.callbacks.FriendMessageCallback +import im.tox.tox4j.core.callbacks.FriendNameCallback +import im.tox.tox4j.core.callbacks.FriendReadReceiptCallback +import im.tox.tox4j.core.callbacks.FriendRequestCallback +import im.tox.tox4j.core.callbacks.FriendStatusCallback +import im.tox.tox4j.core.callbacks.FriendStatusMessageCallback +import im.tox.tox4j.core.callbacks.FriendTypingCallback +import im.tox.tox4j.core.callbacks.GroupCustomPacketCallback +import im.tox.tox4j.core.callbacks.GroupCustomPrivatePacketCallback +import im.tox.tox4j.core.callbacks.GroupInviteCallback +import im.tox.tox4j.core.callbacks.GroupJoinFailCallback +import im.tox.tox4j.core.callbacks.GroupMessageCallback +import im.tox.tox4j.core.callbacks.GroupModerationCallback +import im.tox.tox4j.core.callbacks.GroupPasswordCallback +import im.tox.tox4j.core.callbacks.GroupPeerExitCallback +import im.tox.tox4j.core.callbacks.GroupPeerJoinCallback +import im.tox.tox4j.core.callbacks.GroupPeerLimitCallback +import im.tox.tox4j.core.callbacks.GroupPeerNameCallback +import im.tox.tox4j.core.callbacks.GroupPeerStatusCallback +import im.tox.tox4j.core.callbacks.GroupPrivacyStateCallback +import im.tox.tox4j.core.callbacks.GroupPrivateMessageCallback +import im.tox.tox4j.core.callbacks.GroupSelfJoinCallback +import im.tox.tox4j.core.callbacks.GroupTopicCallback +import im.tox.tox4j.core.callbacks.GroupTopicLockCallback +import im.tox.tox4j.core.callbacks.GroupVoiceStateCallback +import im.tox.tox4j.core.callbacks.SelfConnectionStatusCallback import im.tox.tox4j.core.callbacks.ToxCoreEventListener +import im.tox.tox4j.core.data.ToxConferenceNumber +import im.tox.tox4j.core.data.ToxConferencePeerNumber import im.tox.tox4j.core.data.ToxFilename import im.tox.tox4j.core.data.ToxFriendMessage +import im.tox.tox4j.core.data.ToxFriendMessageId import im.tox.tox4j.core.data.ToxFriendNumber import im.tox.tox4j.core.data.ToxFriendRequestMessage +import im.tox.tox4j.core.data.ToxGroupMessageId +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPartMessage +import im.tox.tox4j.core.data.ToxGroupPassword +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.data.ToxGroupTopic import im.tox.tox4j.core.data.ToxLosslessPacket import im.tox.tox4j.core.data.ToxLossyPacket import im.tox.tox4j.core.data.ToxNickname import im.tox.tox4j.core.data.ToxPublicKey import im.tox.tox4j.core.data.ToxStatusMessage +import im.tox.tox4j.core.enums.ToxConferenceType import im.tox.tox4j.core.enums.ToxConnection import im.tox.tox4j.core.enums.ToxFileControl +import im.tox.tox4j.core.enums.ToxGroupExitType +import im.tox.tox4j.core.enums.ToxGroupJoinFail +import im.tox.tox4j.core.enums.ToxGroupModEvent +import im.tox.tox4j.core.enums.ToxGroupPrivacyState +import im.tox.tox4j.core.enums.ToxGroupTopicLock +import im.tox.tox4j.core.enums.ToxGroupVoiceState import im.tox.tox4j.core.enums.ToxMessageType import im.tox.tox4j.core.enums.ToxUserStatus +import im.tox.tox4j.core.proto.ConferenceConnected +import im.tox.tox4j.core.proto.ConferenceInvite +import im.tox.tox4j.core.proto.ConferenceMessage +import im.tox.tox4j.core.proto.ConferencePeerListChanged +import im.tox.tox4j.core.proto.ConferencePeerName +import im.tox.tox4j.core.proto.ConferenceTitle +import im.tox.tox4j.core.proto.ConferenceType import im.tox.tox4j.core.proto.Connection import im.tox.tox4j.core.proto.CoreEvents import im.tox.tox4j.core.proto.FileChunkRequest @@ -31,6 +93,26 @@ import im.tox.tox4j.core.proto.FriendRequest import im.tox.tox4j.core.proto.FriendStatus import im.tox.tox4j.core.proto.FriendStatusMessage import im.tox.tox4j.core.proto.FriendTyping +import im.tox.tox4j.core.proto.GroupCustomPacket +import im.tox.tox4j.core.proto.GroupCustomPrivatePacket +import im.tox.tox4j.core.proto.GroupExitType +import im.tox.tox4j.core.proto.GroupInvite +import im.tox.tox4j.core.proto.GroupJoinFail +import im.tox.tox4j.core.proto.GroupMessage +import im.tox.tox4j.core.proto.GroupModEvent +import im.tox.tox4j.core.proto.GroupModeration +import im.tox.tox4j.core.proto.GroupPassword +import im.tox.tox4j.core.proto.GroupPeerExit +import im.tox.tox4j.core.proto.GroupPeerJoin +import im.tox.tox4j.core.proto.GroupPeerLimit +import im.tox.tox4j.core.proto.GroupPeerName +import im.tox.tox4j.core.proto.GroupPeerStatus +import im.tox.tox4j.core.proto.GroupPrivacyState +import im.tox.tox4j.core.proto.GroupPrivateMessage +import im.tox.tox4j.core.proto.GroupSelfJoin +import im.tox.tox4j.core.proto.GroupTopic +import im.tox.tox4j.core.proto.GroupTopicLock +import im.tox.tox4j.core.proto.GroupVoiceState import im.tox.tox4j.core.proto.MessageType import im.tox.tox4j.core.proto.SelfConnectionStatus import im.tox.tox4j.core.proto.UserStatus @@ -74,244 +156,706 @@ object ToxCoreEventDispatch { MessageType.Type.UNRECOGNIZED -> ToxMessageType.NORMAL } + fun convert(conferenceType: ConferenceType.Type): ToxConferenceType = + when (conferenceType) { + ConferenceType.Type.TEXT -> ToxConferenceType.TEXT + ConferenceType.Type.AV -> ToxConferenceType.AV + ConferenceType.Type.UNRECOGNIZED -> ToxConferenceType.TEXT + } + + fun convert(groupExitType: GroupExitType.Type): ToxGroupExitType = + when (groupExitType) { + GroupExitType.Type.QUIT -> ToxGroupExitType.QUIT + GroupExitType.Type.TIMEOUT -> ToxGroupExitType.TIMEOUT + GroupExitType.Type.DISCONNECTED -> ToxGroupExitType.DISCONNECTED + GroupExitType.Type.SELF_DISCONNECTED -> ToxGroupExitType.SELF_DISCONNECTED + GroupExitType.Type.KICK -> ToxGroupExitType.KICK + GroupExitType.Type.SYNC_ERROR -> ToxGroupExitType.SYNC_ERROR + GroupExitType.Type.UNRECOGNIZED -> ToxGroupExitType.QUIT + } + + fun convert(groupModEvent: GroupModEvent.Type): ToxGroupModEvent = + when (groupModEvent) { + GroupModEvent.Type.KICK -> ToxGroupModEvent.KICK + GroupModEvent.Type.OBSERVER -> ToxGroupModEvent.OBSERVER + GroupModEvent.Type.USER -> ToxGroupModEvent.USER + GroupModEvent.Type.MODERATOR -> ToxGroupModEvent.MODERATOR + GroupModEvent.Type.UNRECOGNIZED -> ToxGroupModEvent.KICK + } + + fun convert(groupPrivacyState: GroupPrivacyState.Type): ToxGroupPrivacyState = + when (groupPrivacyState) { + GroupPrivacyState.Type.PUBLIC -> ToxGroupPrivacyState.PUBLIC + GroupPrivacyState.Type.PRIVATE -> ToxGroupPrivacyState.PRIVATE + GroupPrivacyState.Type.UNRECOGNIZED -> ToxGroupPrivacyState.PUBLIC + } + + fun convert(groupVoiceState: GroupVoiceState.Type): ToxGroupVoiceState = + when (groupVoiceState) { + GroupVoiceState.Type.ALL -> ToxGroupVoiceState.ALL + GroupVoiceState.Type.MODERATOR -> ToxGroupVoiceState.MODERATOR + GroupVoiceState.Type.FOUNDER -> ToxGroupVoiceState.FOUNDER + GroupVoiceState.Type.UNRECOGNIZED -> ToxGroupVoiceState.ALL + } + + fun convert(groupTopicLock: GroupTopicLock.Type): ToxGroupTopicLock = + when (groupTopicLock) { + GroupTopicLock.Type.ENABLED -> ToxGroupTopicLock.ENABLED + GroupTopicLock.Type.DISABLED -> ToxGroupTopicLock.DISABLED + GroupTopicLock.Type.UNRECOGNIZED -> ToxGroupTopicLock.ENABLED + } + + fun convert(groupJoinFail: GroupJoinFail.Type): ToxGroupJoinFail = + when (groupJoinFail) { + GroupJoinFail.Type.PEER_LIMIT -> ToxGroupJoinFail.PEER_LIMIT + GroupJoinFail.Type.INVALID_PASSWORD -> ToxGroupJoinFail.INVALID_PASSWORD + GroupJoinFail.Type.UNKNOWN -> ToxGroupJoinFail.UNKNOWN + GroupJoinFail.Type.UNRECOGNIZED -> ToxGroupJoinFail.UNKNOWN + } + private fun dispatchSelfConnectionStatus( - handler: ToxCoreEventListener, + handler: SelfConnectionStatusCallback, selfConnectionStatus: List, - state: S, - ): S = - selfConnectionStatus.fold( - state, - { next, ev -> handler.selfConnectionStatus(convert(ev.getConnectionStatus()), next) }, + ): List<(state: S) -> S> = + selfConnectionStatus.map( + { ev -> + { next -> handler.selfConnectionStatus(convert(ev.getConnectionStatus()), next) } + }, ) private fun dispatchFriendName( - handler: ToxCoreEventListener, + handler: FriendNameCallback, friendName: List, - state: S, - ): S = - friendName.fold( - state, - { next, ev -> - handler.friendName( - ToxFriendNumber(ev.getFriendNumber()), - ToxNickname(ev.getName().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + friendName.map( + { ev -> + { next -> + handler.friendName( + ToxFriendNumber(ev.getFriendNumber()), + ToxNickname(ev.getName().toByteArray()), + next, + ) + } }, ) private fun dispatchFriendStatusMessage( - handler: ToxCoreEventListener, + handler: FriendStatusMessageCallback, friendStatusMessage: List, - state: S, - ): S = - friendStatusMessage.fold( - state, - { next, ev -> - handler.friendStatusMessage( - ToxFriendNumber(ev.getFriendNumber()), - ToxStatusMessage(ev.getMessage().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + friendStatusMessage.map( + { ev -> + { next -> + handler.friendStatusMessage( + ToxFriendNumber(ev.getFriendNumber()), + ToxStatusMessage(ev.getMessage().toByteArray()), + next, + ) + } }, ) private fun dispatchFriendStatus( - handler: ToxCoreEventListener, + handler: FriendStatusCallback, friendStatus: List, - state: S, - ): S = - friendStatus.fold( - state, - { next, ev -> - handler.friendStatus( - ToxFriendNumber(ev.getFriendNumber()), - convert(ev.getStatus()), - next, - ) + ): List<(state: S) -> S> = + friendStatus.map( + { ev -> + { next -> + handler.friendStatus( + ToxFriendNumber(ev.getFriendNumber()), + convert(ev.getStatus()), + next, + ) + } }, ) private fun dispatchFriendConnectionStatus( - handler: ToxCoreEventListener, + handler: FriendConnectionStatusCallback, friendConnectionStatus: List, - state: S, - ): S = - friendConnectionStatus.fold( - state, - { next, ev -> - handler.friendConnectionStatus( - ToxFriendNumber(ev.getFriendNumber()), - convert(ev.getConnectionStatus()), - next, - ) + ): List<(state: S) -> S> = + friendConnectionStatus.map( + { ev -> + { next -> + handler.friendConnectionStatus( + ToxFriendNumber(ev.getFriendNumber()), + convert(ev.getConnectionStatus()), + next, + ) + } }, ) private fun dispatchFriendTyping( - handler: ToxCoreEventListener, + handler: FriendTypingCallback, friendTyping: List, - state: S, - ): S = - friendTyping.fold( - state, - { next, ev -> - handler.friendTyping(ToxFriendNumber(ev.getFriendNumber()), ev.getIsTyping(), next) + ): List<(state: S) -> S> = + friendTyping.map( + { ev -> + { next -> + handler.friendTyping( + ToxFriendNumber(ev.getFriendNumber()), + ev.getIsTyping(), + next, + ) + } }, ) private fun dispatchFriendReadReceipt( - handler: ToxCoreEventListener, + handler: FriendReadReceiptCallback, friendReadReceipt: List, - state: S, - ): S = - friendReadReceipt.fold( - state, - { next, ev -> - handler.friendReadReceipt( - ToxFriendNumber(ev.getFriendNumber()), - ev.getMessageId(), - next, - ) + ): List<(state: S) -> S> = + friendReadReceipt.map( + { ev -> + { next -> + handler.friendReadReceipt( + ToxFriendNumber(ev.getFriendNumber()), + ToxFriendMessageId(ev.getMessageId()), + next, + ) + } }, ) private fun dispatchFriendRequest( - handler: ToxCoreEventListener, + handler: FriendRequestCallback, friendRequest: List, - state: S, - ): S = - friendRequest.fold( - state, - { next, ev -> - handler.friendRequest( - ToxPublicKey(ev.getPublicKey().toByteArray()), - ev.getTimeDelta(), - ToxFriendRequestMessage(ev.getMessage().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + friendRequest.map( + { ev -> + { next -> + handler.friendRequest( + ToxPublicKey(ev.getPublicKey().toByteArray()), + ToxFriendRequestMessage(ev.getMessage().toByteArray()), + next, + ) + } }, ) private fun dispatchFriendMessage( - handler: ToxCoreEventListener, + handler: FriendMessageCallback, friendMessage: List, - state: S, - ): S = - friendMessage.fold( - state, - { next, ev -> - handler.friendMessage( - ToxFriendNumber(ev.getFriendNumber()), - convert(ev.getType()), - ev.getTimeDelta(), - ToxFriendMessage(ev.getMessage().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + friendMessage.map( + { ev -> + { next -> + handler.friendMessage( + ToxFriendNumber(ev.getFriendNumber()), + convert(ev.getMessageType()), + ToxFriendMessage(ev.getMessage().toByteArray()), + next, + ) + } }, ) private fun dispatchFileRecvControl( - handler: ToxCoreEventListener, + handler: FileRecvControlCallback, fileRecvControl: List, - state: S, - ): S = - fileRecvControl.fold( - state, - { next, ev -> - handler.fileRecvControl( - ToxFriendNumber(ev.getFriendNumber()), - ev.getFileNumber(), - convert(ev.getControl()), - next, - ) + ): List<(state: S) -> S> = + fileRecvControl.map( + { ev -> + { next -> + handler.fileRecvControl( + ToxFriendNumber(ev.getFriendNumber()), + ev.getFileNumber(), + convert(ev.getControl()), + next, + ) + } }, ) private fun dispatchFileChunkRequest( - handler: ToxCoreEventListener, + handler: FileChunkRequestCallback, fileChunkRequest: List, - state: S, - ): S = - fileChunkRequest.fold( - state, - { next, ev -> - handler.fileChunkRequest( - ToxFriendNumber(ev.getFriendNumber()), - ev.getFileNumber(), - ev.getPosition(), - ev.getLength(), - next, - ) + ): List<(state: S) -> S> = + fileChunkRequest.map( + { ev -> + { next -> + handler.fileChunkRequest( + ToxFriendNumber(ev.getFriendNumber()), + ev.getFileNumber(), + ev.getPosition(), + ev.getLength(), + next, + ) + } }, ) private fun dispatchFileRecv( - handler: ToxCoreEventListener, + handler: FileRecvCallback, fileRecv: List, - state: S, - ): S = - fileRecv.fold( - state, - { next, ev -> - handler.fileRecv( - ToxFriendNumber(ev.getFriendNumber()), - ev.getFileNumber(), - ev.getKind(), - ev.getFileSize(), - ToxFilename(ev.getFilename().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + fileRecv.map( + { ev -> + { next -> + handler.fileRecv( + ToxFriendNumber(ev.getFriendNumber()), + ev.getFileNumber(), + ev.getKind(), + ev.getFileSize(), + ToxFilename(ev.getFilename().toByteArray()), + next, + ) + } }, ) private fun dispatchFileRecvChunk( - handler: ToxCoreEventListener, + handler: FileRecvChunkCallback, fileRecvChunk: List, - state: S, - ): S = - fileRecvChunk.fold( - state, - { next, ev -> - handler.fileRecvChunk( - ToxFriendNumber(ev.getFriendNumber()), - ev.getFileNumber(), - ev.getPosition(), - ev.getData().toByteArray(), - next, - ) + ): List<(state: S) -> S> = + fileRecvChunk.map( + { ev -> + { next -> + handler.fileRecvChunk( + ToxFriendNumber(ev.getFriendNumber()), + ev.getFileNumber(), + ev.getPosition(), + ev.getData().toByteArray(), + next, + ) + } }, ) private fun dispatchFriendLossyPacket( - handler: ToxCoreEventListener, + handler: FriendLossyPacketCallback, friendLossyPacket: List, - state: S, - ): S = - friendLossyPacket.fold( - state, - { next, ev -> - handler.friendLossyPacket( - ToxFriendNumber(ev.getFriendNumber()), - ToxLossyPacket(ev.getData().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + friendLossyPacket.map( + { ev -> + { next -> + handler.friendLossyPacket( + ToxFriendNumber(ev.getFriendNumber()), + ToxLossyPacket(ev.getData().toByteArray()), + next, + ) + } }, ) private fun dispatchFriendLosslessPacket( - handler: ToxCoreEventListener, + handler: FriendLosslessPacketCallback, friendLosslessPacket: List, - state: S, - ): S = - friendLosslessPacket.fold( - state, - { next, ev -> - handler.friendLosslessPacket( - ToxFriendNumber(ev.getFriendNumber()), - ToxLosslessPacket(ev.getData().toByteArray()), - next, - ) + ): List<(state: S) -> S> = + friendLosslessPacket.map( + { ev -> + { next -> + handler.friendLosslessPacket( + ToxFriendNumber(ev.getFriendNumber()), + ToxLosslessPacket(ev.getData().toByteArray()), + next, + ) + } + }, + ) + + private fun dispatchConferenceConnected( + handler: ConferenceConnectedCallback, + conferenceConnected: List, + ): List<(state: S) -> S> = + conferenceConnected.map( + { ev -> + { next -> + handler.conferenceConnected( + ToxConferenceNumber(ev.getConferenceNumber()), + next, + ) + } + }, + ) + + private fun dispatchConferenceInvite( + handler: ConferenceInviteCallback, + conferenceInvite: List, + ): List<(state: S) -> S> = + conferenceInvite.map( + { ev -> + { next -> + handler.conferenceInvite( + ToxFriendNumber(ev.getFriendNumber()), + convert(ev.getType()), + ev.getCookie().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchConferenceMessage( + handler: ConferenceMessageCallback, + conferenceMessage: List, + ): List<(state: S) -> S> = + conferenceMessage.map( + { ev -> + { next -> + handler.conferenceMessage( + ToxConferenceNumber(ev.getConferenceNumber()), + ToxConferencePeerNumber(ev.getPeerNumber()), + convert(ev.getMessageType()), + ev.getMessage().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchConferencePeerListChanged( + handler: ConferencePeerListChangedCallback, + conferencePeerListChanged: List, + ): List<(state: S) -> S> = + conferencePeerListChanged.map( + { ev -> + { next -> + handler.conferencePeerListChanged( + ToxConferenceNumber(ev.getConferenceNumber()), + next, + ) + } + }, + ) + + private fun dispatchConferencePeerName( + handler: ConferencePeerNameCallback, + conferencePeerName: List, + ): List<(state: S) -> S> = + conferencePeerName.map( + { ev -> + { next -> + handler.conferencePeerName( + ToxConferenceNumber(ev.getConferenceNumber()), + ToxConferencePeerNumber(ev.getPeerNumber()), + ev.getName().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchConferenceTitle( + handler: ConferenceTitleCallback, + conferenceTitle: List, + ): List<(state: S) -> S> = + conferenceTitle.map( + { ev -> + { next -> + handler.conferenceTitle( + ToxConferenceNumber(ev.getConferenceNumber()), + ToxConferencePeerNumber(ev.getPeerNumber()), + ev.getTitle().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchGroupCustomPacket( + handler: GroupCustomPacketCallback, + groupCustomPacket: List, + ): List<(state: S) -> S> = + groupCustomPacket.map( + { ev -> + { next -> + handler.groupCustomPacket( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + ev.getData().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchGroupCustomPrivatePacket( + handler: GroupCustomPrivatePacketCallback, + groupCustomPrivatePacket: List, + ): List<(state: S) -> S> = + groupCustomPrivatePacket.map( + { ev -> + { next -> + handler.groupCustomPrivatePacket( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + ev.getData().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchGroupInvite( + handler: GroupInviteCallback, + groupInvite: List, + ): List<(state: S) -> S> = + groupInvite.map( + { ev -> + { next -> + handler.groupInvite( + ToxFriendNumber(ev.getFriendNumber()), + ev.getInviteData().toByteArray(), + ev.getGroupName().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchGroupJoinFail( + handler: GroupJoinFailCallback, + groupJoinFail: List, + ): List<(state: S) -> S> = + groupJoinFail.map( + { ev -> + { next -> + handler.groupJoinFail( + ToxGroupNumber(ev.getGroupNumber()), + convert(ev.getFailType()), + next, + ) + } + }, + ) + + private fun dispatchGroupMessage( + handler: GroupMessageCallback, + groupMessage: List, + ): List<(state: S) -> S> = + groupMessage.map( + { ev -> + { next -> + handler.groupMessage( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + convert(ev.getMessageType()), + ev.getMessage().toByteArray(), + ToxGroupMessageId(ev.getMessageId()), + next, + ) + } + }, + ) + + private fun dispatchGroupModeration( + handler: GroupModerationCallback, + groupModeration: List, + ): List<(state: S) -> S> = + groupModeration.map( + { ev -> + { next -> + handler.groupModeration( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getSourcePeerId()), + ToxGroupPeerNumber(ev.getTargetPeerId()), + convert(ev.getModType()), + next, + ) + } + }, + ) + + private fun dispatchGroupPassword( + handler: GroupPasswordCallback, + groupPassword: List, + ): List<(state: S) -> S> = + groupPassword.map( + { ev -> + { next -> + handler.groupPassword( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPassword(ev.getPassword().toByteArray()), + next, + ) + } + }, + ) + + private fun dispatchGroupPeerExit( + handler: GroupPeerExitCallback, + groupPeerExit: List, + ): List<(state: S) -> S> = + groupPeerExit.map( + { ev -> + { next -> + handler.groupPeerExit( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + convert(ev.getExitType()), + ev.getName().toByteArray(), + ToxGroupPartMessage(ev.getPartMessage().toByteArray()), + next, + ) + } + }, + ) + + private fun dispatchGroupPeerJoin( + handler: GroupPeerJoinCallback, + groupPeerJoin: List, + ): List<(state: S) -> S> = + groupPeerJoin.map( + { ev -> + { next -> + handler.groupPeerJoin( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + next, + ) + } + }, + ) + + private fun dispatchGroupPeerLimit( + handler: GroupPeerLimitCallback, + groupPeerLimit: List, + ): List<(state: S) -> S> = + groupPeerLimit.map( + { ev -> + { next -> + handler.groupPeerLimit( + ToxGroupNumber(ev.getGroupNumber()), + ev.getPeerLimit(), + next, + ) + } + }, + ) + + private fun dispatchGroupPeerName( + handler: GroupPeerNameCallback, + groupPeerName: List, + ): List<(state: S) -> S> = + groupPeerName.map( + { ev -> + { next -> + handler.groupPeerName( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + ev.getName().toByteArray(), + next, + ) + } + }, + ) + + private fun dispatchGroupPeerStatus( + handler: GroupPeerStatusCallback, + groupPeerStatus: List, + ): List<(state: S) -> S> = + groupPeerStatus.map( + { ev -> + { next -> + handler.groupPeerStatus( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + convert(ev.getStatus()), + next, + ) + } + }, + ) + + private fun dispatchGroupPrivacyState( + handler: GroupPrivacyStateCallback, + groupPrivacyState: List, + ): List<(state: S) -> S> = + groupPrivacyState.map( + { ev -> + { next -> + handler.groupPrivacyState( + ToxGroupNumber(ev.getGroupNumber()), + convert(ev.getPrivacyState()), + next, + ) + } + }, + ) + + private fun dispatchGroupPrivateMessage( + handler: GroupPrivateMessageCallback, + groupPrivateMessage: List, + ): List<(state: S) -> S> = + groupPrivateMessage.map( + { ev -> + { next -> + handler.groupPrivateMessage( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + convert(ev.getMessageType()), + ev.getMessage().toByteArray(), + ToxGroupMessageId(ev.getMessageId()), + next, + ) + } + }, + ) + + private fun dispatchGroupSelfJoin( + handler: GroupSelfJoinCallback, + groupSelfJoin: List, + ): List<(state: S) -> S> = + groupSelfJoin.map( + { ev -> + { next -> + handler.groupSelfJoin( + ToxGroupNumber(ev.getGroupNumber()), + next, + ) + } + }, + ) + + private fun dispatchGroupTopic( + handler: GroupTopicCallback, + groupTopic: List, + ): List<(state: S) -> S> = + groupTopic.map( + { ev -> + { next -> + handler.groupTopic( + ToxGroupNumber(ev.getGroupNumber()), + ToxGroupPeerNumber(ev.getPeerId()), + ToxGroupTopic(ev.getTopic().toByteArray()), + next, + ) + } + }, + ) + + private fun dispatchGroupTopicLock( + handler: GroupTopicLockCallback, + groupTopicLock: List, + ): List<(state: S) -> S> = + groupTopicLock.map( + { ev -> + { next -> + handler.groupTopicLock( + ToxGroupNumber(ev.getGroupNumber()), + convert(ev.getTopicLock()), + next, + ) + } + }, + ) + + private fun dispatchGroupVoiceState( + handler: GroupVoiceStateCallback, + groupVoiceState: List, + ): List<(state: S) -> S> = + groupVoiceState.map( + { ev -> + { next -> + handler.groupVoiceState( + ToxGroupNumber(ev.getGroupNumber()), + convert(ev.getVoiceState()), + next, + ) + } }, ) @@ -320,68 +864,49 @@ object ToxCoreEventDispatch { events: CoreEvents, state: S, ): S = - dispatchSelfConnectionStatus( - handler, - events.getSelfConnectionStatusList(), - dispatchFriendName( - handler, - events.getFriendNameList(), - dispatchFriendStatusMessage( - handler, - events.getFriendStatusMessageList(), - dispatchFriendStatus( - handler, - events.getFriendStatusList(), - dispatchFriendConnectionStatus( - handler, - events.getFriendConnectionStatusList(), - dispatchFriendTyping( - handler, - events.getFriendTypingList(), - dispatchFriendReadReceipt( - handler, - events.getFriendReadReceiptList(), - dispatchFriendRequest( - handler, - events.getFriendRequestList(), - dispatchFriendMessage( - handler, - events.getFriendMessageList(), - dispatchFileRecvControl( - handler, - events.getFileRecvControlList(), - dispatchFileChunkRequest( - handler, - events.getFileChunkRequestList(), - dispatchFileRecv( - handler, - events.getFileRecvList(), - dispatchFileRecvChunk( - handler, - events.getFileRecvChunkList(), - dispatchFriendLossyPacket( - handler, - events.getFriendLossyPacketList(), - dispatchFriendLosslessPacket( - handler, - events - .getFriendLosslessPacketList(), - state, - ), - ), - ), - ), - ), - ), - ), - ), - ), - ), - ), - ), - ), - ), + listOf( + dispatchSelfConnectionStatus(handler, events.getSelfConnectionStatusList()), + dispatchFriendName(handler, events.getFriendNameList()), + dispatchFriendStatusMessage(handler, events.getFriendStatusMessageList()), + dispatchFriendStatus(handler, events.getFriendStatusList()), + dispatchFriendConnectionStatus(handler, events.getFriendConnectionStatusList()), + dispatchFriendTyping(handler, events.getFriendTypingList()), + dispatchFriendReadReceipt(handler, events.getFriendReadReceiptList()), + dispatchFriendRequest(handler, events.getFriendRequestList()), + dispatchFriendMessage(handler, events.getFriendMessageList()), + dispatchFileRecvControl(handler, events.getFileRecvControlList()), + dispatchFileChunkRequest(handler, events.getFileChunkRequestList()), + dispatchFileRecv(handler, events.getFileRecvList()), + dispatchFileRecvChunk(handler, events.getFileRecvChunkList()), + dispatchFriendLossyPacket(handler, events.getFriendLossyPacketList()), + dispatchFriendLosslessPacket(handler, events.getFriendLosslessPacketList()), + dispatchConferenceConnected(handler, events.getConferenceConnectedList()), + dispatchConferenceInvite(handler, events.getConferenceInviteList()), + dispatchConferenceMessage(handler, events.getConferenceMessageList()), + dispatchConferencePeerListChanged(handler, events.getConferencePeerListChangedList()), + dispatchConferencePeerName(handler, events.getConferencePeerNameList()), + dispatchConferenceTitle(handler, events.getConferenceTitleList()), + dispatchGroupCustomPacket(handler, events.getGroupCustomPacketList()), + dispatchGroupCustomPrivatePacket(handler, events.getGroupCustomPrivatePacketList()), + dispatchGroupInvite(handler, events.getGroupInviteList()), + dispatchGroupJoinFail(handler, events.getGroupJoinFailList()), + dispatchGroupMessage(handler, events.getGroupMessageList()), + dispatchGroupModeration(handler, events.getGroupModerationList()), + dispatchGroupPassword(handler, events.getGroupPasswordList()), + dispatchGroupPeerExit(handler, events.getGroupPeerExitList()), + dispatchGroupPeerJoin(handler, events.getGroupPeerJoinList()), + dispatchGroupPeerLimit(handler, events.getGroupPeerLimitList()), + dispatchGroupPeerName(handler, events.getGroupPeerNameList()), + dispatchGroupPeerStatus(handler, events.getGroupPeerStatusList()), + dispatchGroupPrivacyState(handler, events.getGroupPrivacyStateList()), + dispatchGroupPrivateMessage(handler, events.getGroupPrivateMessageList()), + dispatchGroupSelfJoin(handler, events.getGroupSelfJoinList()), + dispatchGroupTopic(handler, events.getGroupTopicList()), + dispatchGroupTopicLock(handler, events.getGroupTopicLockList()), + dispatchGroupVoiceState(handler, events.getGroupVoiceStateList()), ) + .flatten() + .fold(state, { next, f -> f(next) }) fun dispatch( handler: ToxCoreEventListener, diff --git a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreImpl.kt b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreImpl.kt index 4f0b2167b..4a37b6598 100644 --- a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreImpl.kt +++ b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreImpl.kt @@ -4,19 +4,42 @@ import im.tox.tox4j.core.ToxCore import im.tox.tox4j.core.ToxCoreConstants import im.tox.tox4j.core.callbacks.ToxCoreEventListener import im.tox.tox4j.core.data.Port +import im.tox.tox4j.core.data.ToxConferenceId +import im.tox.tox4j.core.data.ToxConferenceMessage +import im.tox.tox4j.core.data.ToxConferenceNumber +import im.tox.tox4j.core.data.ToxConferenceOfflinePeerNumber +import im.tox.tox4j.core.data.ToxConferencePeerName +import im.tox.tox4j.core.data.ToxConferencePeerNumber +import im.tox.tox4j.core.data.ToxConferenceTitle +import im.tox.tox4j.core.data.ToxConferenceUid import im.tox.tox4j.core.data.ToxFileId import im.tox.tox4j.core.data.ToxFilename import im.tox.tox4j.core.data.ToxFriendAddress import im.tox.tox4j.core.data.ToxFriendMessage +import im.tox.tox4j.core.data.ToxFriendMessageId import im.tox.tox4j.core.data.ToxFriendNumber import im.tox.tox4j.core.data.ToxFriendRequestMessage +import im.tox.tox4j.core.data.ToxGroupChatId +import im.tox.tox4j.core.data.ToxGroupMessage +import im.tox.tox4j.core.data.ToxGroupName +import im.tox.tox4j.core.data.ToxGroupNumber +import im.tox.tox4j.core.data.ToxGroupPartMessage +import im.tox.tox4j.core.data.ToxGroupPassword +import im.tox.tox4j.core.data.ToxGroupPeerNumber +import im.tox.tox4j.core.data.ToxGroupTopic import im.tox.tox4j.core.data.ToxLosslessPacket import im.tox.tox4j.core.data.ToxLossyPacket import im.tox.tox4j.core.data.ToxNickname import im.tox.tox4j.core.data.ToxPublicKey import im.tox.tox4j.core.data.ToxSecretKey import im.tox.tox4j.core.data.ToxStatusMessage +import im.tox.tox4j.core.enums.ToxConferenceType +import im.tox.tox4j.core.enums.ToxConnection import im.tox.tox4j.core.enums.ToxFileControl +import im.tox.tox4j.core.enums.ToxGroupPrivacyState +import im.tox.tox4j.core.enums.ToxGroupRole +import im.tox.tox4j.core.enums.ToxGroupTopicLock +import im.tox.tox4j.core.enums.ToxGroupVoiceState import im.tox.tox4j.core.enums.ToxMessageType import im.tox.tox4j.core.enums.ToxUserStatus import im.tox.tox4j.core.exceptions.ToxBootstrapException @@ -106,7 +129,8 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { override val getAddress: ToxFriendAddress get() = ToxFriendAddress(ToxCoreJni.toxSelfGetAddress(instanceNumber)) - override fun setName(name: ToxNickname): Unit = ToxCoreJni.toxSelfSetName(instanceNumber, name.value) + override fun setName(name: ToxNickname): Unit = + ToxCoreJni.toxSelfSetName(instanceNumber, name.value) override val getName: ToxNickname get() = ToxNickname(ToxCoreJni.toxSelfGetName(instanceNumber)) @@ -118,7 +142,8 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { override val getStatusMessage: ToxStatusMessage get() = ToxStatusMessage(ToxCoreJni.toxSelfGetStatusMessage(instanceNumber)) - override fun setStatus(status: ToxUserStatus): Unit = ToxCoreJni.toxSelfSetStatus(instanceNumber, status.ordinal) + override fun setStatus(status: ToxUserStatus): Unit = + ToxCoreJni.toxSelfSetStatus(instanceNumber, status.ordinal) override val getStatus: ToxUserStatus get() = ToxUserStatus.values()[ToxCoreJni.toxSelfGetStatus(instanceNumber)] @@ -128,7 +153,9 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { message: ToxFriendRequestMessage, ): ToxFriendNumber { ToxCoreImpl.checkLength("Friend Address", address.value, ToxCoreConstants.ADDRESS_SIZE) - return ToxFriendNumber(ToxCoreJni.toxFriendAdd(instanceNumber, address.value, message.value)) + return ToxFriendNumber( + ToxCoreJni.toxFriendAdd(instanceNumber, address.value, message.value), + ) } override fun addFriendNorequest(publicKey: ToxPublicKey): ToxFriendNumber { @@ -136,7 +163,8 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { return ToxFriendNumber(ToxCoreJni.toxFriendAddNorequest(instanceNumber, publicKey.value)) } - override fun deleteFriend(friendNumber: ToxFriendNumber): Unit = ToxCoreJni.toxFriendDelete(instanceNumber, friendNumber.value) + override fun deleteFriend(friendNumber: ToxFriendNumber): Unit = + ToxCoreJni.toxFriendDelete(instanceNumber, friendNumber.value) override fun friendByPublicKey(publicKey: ToxPublicKey): ToxFriendNumber = ToxFriendNumber(ToxCoreJni.toxFriendByPublicKey(instanceNumber, publicKey.value)) @@ -144,7 +172,8 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { override fun getFriendPublicKey(friendNumber: ToxFriendNumber): ToxPublicKey = ToxPublicKey(ToxCoreJni.toxFriendGetPublicKey(instanceNumber, friendNumber.value)) - override fun friendExists(friendNumber: ToxFriendNumber): Boolean = ToxCoreJni.toxFriendExists(instanceNumber, friendNumber.value) + override fun friendExists(friendNumber: ToxFriendNumber): Boolean = + ToxCoreJni.toxFriendExists(instanceNumber, friendNumber.value) override val getFriendList: IntArray get() = ToxCoreJni.toxSelfGetFriendList(instanceNumber) @@ -157,22 +186,23 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { override fun friendSendMessage( friendNumber: ToxFriendNumber, messageType: ToxMessageType, - timeDelta: Int, message: ToxFriendMessage, - ): Int = - ToxCoreJni.toxFriendSendMessage( - instanceNumber, - friendNumber.value, - messageType.ordinal, - timeDelta, - message.value, + ): ToxFriendMessageId = + ToxFriendMessageId( + ToxCoreJni.toxFriendSendMessage( + instanceNumber, + friendNumber.value, + messageType.ordinal, + message.value, + ), ) override fun fileControl( friendNumber: ToxFriendNumber, fileNumber: Int, control: ToxFileControl, - ): Unit = ToxCoreJni.toxFileControl(instanceNumber, friendNumber.value, fileNumber, control.ordinal) + ): Unit = + ToxCoreJni.toxFileControl(instanceNumber, friendNumber.value, fileNumber, control.ordinal) override fun fileSeek( friendNumber: ToxFriendNumber, @@ -201,12 +231,14 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { fileNumber: Int, position: Long, data: ByteArray, - ): Unit = ToxCoreJni.toxFileSendChunk(instanceNumber, friendNumber.value, fileNumber, position, data) + ): Unit = + ToxCoreJni.toxFileSendChunk(instanceNumber, friendNumber.value, fileNumber, position, data) override fun getFileFileId( friendNumber: ToxFriendNumber, fileNumber: Int, - ): ToxFileId = ToxFileId(ToxCoreJni.toxFileGetFileId(instanceNumber, friendNumber.value, fileNumber)) + ): ToxFileId = + ToxFileId(ToxCoreJni.toxFileGetFileId(instanceNumber, friendNumber.value, fileNumber)) override fun friendSendLossyPacket( friendNumber: ToxFriendNumber, @@ -218,6 +250,391 @@ final class ToxCoreImpl(val options: ToxOptions) : ToxCore { data: ToxLosslessPacket, ): Unit = ToxCoreJni.toxFriendSendLosslessPacket(instanceNumber, friendNumber.value, data.value) + override fun conferenceNew(): ToxConferenceNumber = + ToxConferenceNumber(ToxCoreJni.toxConferenceNew(instanceNumber)) + + override fun conferenceDelete(conferenceNumber: ToxConferenceNumber): Unit = + ToxCoreJni.toxConferenceDelete(instanceNumber, conferenceNumber.value) + + override fun conferencePeerCount(conferenceNumber: ToxConferenceNumber): Int = + ToxCoreJni.toxConferencePeerCount(instanceNumber, conferenceNumber.value) + + override fun conferencePeerGetName( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + ): ToxConferencePeerName = + ToxConferencePeerName( + ToxCoreJni.toxConferencePeerGetName( + instanceNumber, + conferenceNumber.value, + peerNumber.value, + ), + ) + + override fun conferencePeerGetPublicKey( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + ): ToxPublicKey = + ToxPublicKey( + ToxCoreJni.toxConferencePeerGetPublicKey( + instanceNumber, + conferenceNumber.value, + peerNumber.value, + ), + ) + + override fun conferencePeerNumberIsOurs( + conferenceNumber: ToxConferenceNumber, + peerNumber: ToxConferencePeerNumber, + ): Boolean = + ToxCoreJni.toxConferencePeerNumberIsOurs( + instanceNumber, + conferenceNumber.value, + peerNumber.value, + ) + + override fun conferenceOfflinePeerCount(conferenceNumber: ToxConferenceNumber): Int = + ToxCoreJni.toxConferenceOfflinePeerCount(instanceNumber, conferenceNumber.value) + + override fun conferenceOfflinePeerGetName( + conferenceNumber: ToxConferenceNumber, + offlinePeerNumber: ToxConferenceOfflinePeerNumber, + ): ToxConferencePeerName = + ToxConferencePeerName( + ToxCoreJni.toxConferenceOfflinePeerGetName( + instanceNumber, + conferenceNumber.value, + offlinePeerNumber.value, + ), + ) + + override fun conferenceOfflinePeerGetPublicKey( + conferenceNumber: ToxConferenceNumber, + offlinePeerNumber: ToxConferenceOfflinePeerNumber, + ): ToxPublicKey = + ToxPublicKey( + ToxCoreJni.toxConferenceOfflinePeerGetPublicKey( + instanceNumber, + conferenceNumber.value, + offlinePeerNumber.value, + ), + ) + + override fun conferenceOfflinePeerGetLastActive( + conferenceNumber: ToxConferenceNumber, + offlinePeerNumber: ToxConferenceOfflinePeerNumber, + ): Long = + ToxCoreJni.toxConferenceOfflinePeerGetLastActive( + instanceNumber, + conferenceNumber.value, + offlinePeerNumber.value, + ) + + override fun conferenceSetMaxOffline( + conferenceNumber: ToxConferenceNumber, + maxOffline: Int, + ): Unit = + ToxCoreJni.toxConferenceSetMaxOffline(instanceNumber, conferenceNumber.value, maxOffline) + + override fun conferenceInvite( + friendNumber: ToxFriendNumber, + conferenceNumber: ToxConferenceNumber, + ): Unit = + ToxCoreJni.toxConferenceInvite(instanceNumber, friendNumber.value, conferenceNumber.value) + + override fun conferenceJoin( + friendNumber: ToxFriendNumber, + cookie: ByteArray, + ): ToxConferenceNumber = + ToxConferenceNumber( + ToxCoreJni.toxConferenceJoin(instanceNumber, friendNumber.value, cookie), + ) + + override fun conferenceSendMessage( + conferenceNumber: ToxConferenceNumber, + messageType: ToxMessageType, + message: ToxConferenceMessage, + ): Unit = + ToxCoreJni.toxConferenceSendMessage( + instanceNumber, + conferenceNumber.value, + messageType.ordinal, + message.value, + ) + + override fun conferenceGetTitle(conferenceNumber: ToxConferenceNumber): ToxConferenceTitle = + ToxConferenceTitle(ToxCoreJni.toxConferenceGetTitle(instanceNumber, conferenceNumber.value)) + + override fun conferenceSetTitle( + conferenceNumber: ToxConferenceNumber, + title: ToxConferenceTitle, + ): Unit = ToxCoreJni.toxConferenceSetTitle(instanceNumber, conferenceNumber.value, title.value) + + override val conferenceGetChatlist: IntArray + get() = ToxCoreJni.toxConferenceGetChatlist(instanceNumber) + + override fun conferenceGetType(conferenceNumber: ToxConferenceNumber): ToxConferenceType = + ToxConferenceType.values()[ + ToxCoreJni.toxConferenceGetType(instanceNumber, conferenceNumber.value), + ] + + override fun conferenceGetId(conferenceNumber: ToxConferenceNumber): ToxConferenceId = + ToxConferenceId(ToxCoreJni.toxConferenceGetId(instanceNumber, conferenceNumber.value)) + + override fun conferenceById(conferenceId: ToxConferenceId): ToxConferenceNumber = + ToxConferenceNumber(ToxCoreJni.toxConferenceById(instanceNumber, conferenceId.value)) + + override fun conferenceGetUid(conferenceNumber: ToxConferenceNumber): ToxConferenceUid = + ToxConferenceUid(ToxCoreJni.toxConferenceGetUid(instanceNumber, conferenceNumber.value)) + + override fun conferenceByUid(conferenceUid: ToxConferenceUid): ToxConferenceNumber = + ToxConferenceNumber(ToxCoreJni.toxConferenceByUid(instanceNumber, conferenceUid.value)) + + override fun groupNew( + privacyState: ToxGroupPrivacyState, + groupName: ToxGroupName, + name: ToxGroupName, + ): ToxGroupNumber = + ToxGroupNumber( + ToxCoreJni.toxGroupNew( + instanceNumber, + privacyState.ordinal, + groupName.value, + name.value, + ), + ) + + override fun groupJoin( + chatId: ToxGroupChatId, + name: ToxGroupName, + password: ToxGroupPassword, + ): ToxGroupNumber = + ToxGroupNumber( + ToxCoreJni.toxGroupJoin(instanceNumber, chatId.value, name.value, password.value), + ) + + override fun groupIsConnected(groupNumber: ToxGroupNumber): Boolean = + ToxCoreJni.toxGroupIsConnected(instanceNumber, groupNumber.value) + + override fun groupDisconnect(groupNumber: ToxGroupNumber): Unit = + ToxCoreJni.toxGroupDisconnect(instanceNumber, groupNumber.value) + + override fun groupReconnect(groupNumber: ToxGroupNumber): Unit = + ToxCoreJni.toxGroupReconnect(instanceNumber, groupNumber.value) + + override fun groupLeave(groupNumber: ToxGroupNumber, partMessage: ToxGroupPartMessage): Unit = + ToxCoreJni.toxGroupLeave(instanceNumber, groupNumber.value, partMessage.value) + + override fun groupSelfSetName(groupNumber: ToxGroupNumber, name: ToxGroupName): Unit = + ToxCoreJni.toxGroupSelfSetName(instanceNumber, groupNumber.value, name.value) + + override fun groupSelfGetName(groupNumber: ToxGroupNumber): ToxGroupName = + ToxGroupName(ToxCoreJni.toxGroupSelfGetName(instanceNumber, groupNumber.value)) + + override fun groupSelfSetStatus(groupNumber: ToxGroupNumber, status: ToxUserStatus): Unit = + ToxCoreJni.toxGroupSelfSetStatus(instanceNumber, groupNumber.value, status.ordinal) + + override fun groupSelfGetStatus(groupNumber: ToxGroupNumber): ToxUserStatus = + ToxUserStatus.values()[ToxCoreJni.toxGroupSelfGetStatus(instanceNumber, groupNumber.value)] + + override fun groupSelfGetRole(groupNumber: ToxGroupNumber): ToxGroupRole = + ToxGroupRole.values()[ToxCoreJni.toxGroupSelfGetRole(instanceNumber, groupNumber.value)] + + override fun groupSelfGetPeerId(groupNumber: ToxGroupNumber): ToxGroupPeerNumber = + ToxGroupPeerNumber(ToxCoreJni.toxGroupSelfGetPeerId(instanceNumber, groupNumber.value)) + + override fun groupSelfGetPublicKey(groupNumber: ToxGroupNumber): ToxPublicKey = + ToxPublicKey(ToxCoreJni.toxGroupSelfGetPublicKey(instanceNumber, groupNumber.value)) + + override fun groupPeerGetName( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxGroupName = + ToxGroupName( + ToxCoreJni.toxGroupPeerGetName(instanceNumber, groupNumber.value, peerId.value), + ) + + override fun groupPeerGetStatus( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxUserStatus = + ToxUserStatus.values()[ + ToxCoreJni.toxGroupPeerGetStatus(instanceNumber, groupNumber.value, peerId.value), + ] + + override fun groupPeerGetRole( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxGroupRole = + ToxGroupRole.values()[ + ToxCoreJni.toxGroupPeerGetRole(instanceNumber, groupNumber.value, peerId.value), + ] + + override fun groupPeerGetConnectionStatus( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxConnection = + ToxConnection.values()[ + ToxCoreJni.toxGroupPeerGetConnectionStatus( + instanceNumber, + groupNumber.value, + peerId.value, + ), + ] + + override fun groupPeerGetPublicKey( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): ToxPublicKey = + ToxPublicKey( + ToxCoreJni.toxGroupPeerGetPublicKey(instanceNumber, groupNumber.value, peerId.value), + ) + + override fun groupSetTopic(groupNumber: ToxGroupNumber, topic: ToxGroupTopic): Unit = + ToxCoreJni.toxGroupSetTopic(instanceNumber, groupNumber.value, topic.value) + + override fun groupGetTopic(groupNumber: ToxGroupNumber): ToxGroupTopic = + ToxGroupTopic(ToxCoreJni.toxGroupGetTopic(instanceNumber, groupNumber.value)) + + override fun groupGetName(groupNumber: ToxGroupNumber): ToxGroupName = + ToxGroupName(ToxCoreJni.toxGroupGetName(instanceNumber, groupNumber.value)) + + override fun groupGetChatId(groupNumber: ToxGroupNumber): ToxGroupChatId = + ToxGroupChatId(ToxCoreJni.toxGroupGetChatId(instanceNumber, groupNumber.value)) + + override fun groupGetPrivacyState(groupNumber: ToxGroupNumber): ToxGroupPrivacyState = + ToxGroupPrivacyState.values()[ + ToxCoreJni.toxGroupGetPrivacyState(instanceNumber, groupNumber.value), + ] + + override fun groupGetVoiceState(groupNumber: ToxGroupNumber): ToxGroupVoiceState = + ToxGroupVoiceState.values()[ + ToxCoreJni.toxGroupGetVoiceState(instanceNumber, groupNumber.value), + ] + + override fun groupGetTopicLock(groupNumber: ToxGroupNumber): ToxGroupTopicLock = + ToxGroupTopicLock.values()[ + ToxCoreJni.toxGroupGetTopicLock(instanceNumber, groupNumber.value), + ] + + override fun groupGetPeerLimit(groupNumber: ToxGroupNumber): Int = + ToxCoreJni.toxGroupGetPeerLimit(instanceNumber, groupNumber.value) + + override fun groupGetPassword(groupNumber: ToxGroupNumber): ToxGroupPassword = + ToxGroupPassword(ToxCoreJni.toxGroupGetPassword(instanceNumber, groupNumber.value)) + + override fun groupSendMessage( + groupNumber: ToxGroupNumber, + messageType: ToxMessageType, + message: ToxGroupMessage, + ): Int = + ToxCoreJni.toxGroupSendMessage( + instanceNumber, + groupNumber.value, + messageType.ordinal, + message.value, + ) + + override fun groupSendPrivateMessage( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + messageType: ToxMessageType, + message: ToxGroupMessage, + ): Int = + ToxCoreJni.toxGroupSendPrivateMessage( + instanceNumber, + groupNumber.value, + peerId.value, + messageType.ordinal, + message.value, + ) + + override fun groupSendCustomPacket( + groupNumber: ToxGroupNumber, + lossless: Boolean, + data: ByteArray, + ): Unit = ToxCoreJni.toxGroupSendCustomPacket(instanceNumber, groupNumber.value, lossless, data) + + override fun groupSendCustomPrivatePacket( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + lossless: Boolean, + data: ByteArray, + ): Unit = + ToxCoreJni.toxGroupSendCustomPrivatePacket( + instanceNumber, + groupNumber.value, + peerId.value, + lossless, + data, + ) + + override fun groupInviteFriend( + groupNumber: ToxGroupNumber, + friendNumber: ToxFriendNumber, + ): Unit = ToxCoreJni.toxGroupInviteFriend(instanceNumber, groupNumber.value, friendNumber.value) + + override fun groupInviteAccept( + friendNumber: ToxFriendNumber, + inviteData: ByteArray, + name: ToxGroupName, + password: ToxGroupPassword, + ): ToxGroupNumber = + ToxGroupNumber( + ToxCoreJni.toxGroupInviteAccept( + instanceNumber, + friendNumber.value, + inviteData, + name.value, + password.value, + ), + ) + + override fun groupSetPassword( + groupNumber: ToxGroupNumber, + password: ToxGroupPassword, + ): Unit = ToxCoreJni.toxGroupSetPassword(instanceNumber, groupNumber.value, password.value) + + override fun groupSetTopicLock( + groupNumber: ToxGroupNumber, + topicLock: ToxGroupTopicLock, + ): Unit = ToxCoreJni.toxGroupSetTopicLock(instanceNumber, groupNumber.value, topicLock.ordinal) + + override fun groupSetVoiceState( + groupNumber: ToxGroupNumber, + voiceState: ToxGroupVoiceState, + ): Unit = + ToxCoreJni.toxGroupSetVoiceState(instanceNumber, groupNumber.value, voiceState.ordinal) + + override fun groupSetPrivacyState( + groupNumber: ToxGroupNumber, + privacyState: ToxGroupPrivacyState, + ): Unit = + ToxCoreJni.toxGroupSetPrivacyState(instanceNumber, groupNumber.value, privacyState.ordinal) + + override fun groupSetPeerLimit( + groupNumber: ToxGroupNumber, + peerLimit: Int, + ): Unit = ToxCoreJni.toxGroupSetPeerLimit(instanceNumber, groupNumber.value, peerLimit) + + override fun groupSetIgnore( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ignore: Boolean, + ): Unit = ToxCoreJni.toxGroupSetIgnore(instanceNumber, groupNumber.value, peerId.value, ignore) + + override fun groupSetRole( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + role: ToxGroupRole, + ): Unit = + ToxCoreJni.toxGroupSetRole(instanceNumber, groupNumber.value, peerId.value, role.ordinal) + + override fun groupKickPeer( + groupNumber: ToxGroupNumber, + peerId: ToxGroupPeerNumber, + ): Unit = ToxCoreJni.toxGroupKickPeer(instanceNumber, groupNumber.value, peerId.value) + private companion object { fun checkBootstrapArguments(publicKey: ByteArray) { if (publicKey.size < ToxCoreConstants.PUBLIC_KEY_SIZE) { diff --git a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreJni.java b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreJni.java index 535f2e57a..070d1cca1 100644 --- a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreJni.java +++ b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCoreJni.java @@ -1,6 +1,17 @@ package im.tox.tox4j.impl.jni; import im.tox.tox4j.core.exceptions.ToxBootstrapException; +import im.tox.tox4j.core.exceptions.ToxConferenceByIdException; +import im.tox.tox4j.core.exceptions.ToxConferenceByUidException; +import im.tox.tox4j.core.exceptions.ToxConferenceDeleteException; +import im.tox.tox4j.core.exceptions.ToxConferenceGetTypeException; +import im.tox.tox4j.core.exceptions.ToxConferenceInviteException; +import im.tox.tox4j.core.exceptions.ToxConferenceJoinException; +import im.tox.tox4j.core.exceptions.ToxConferenceNewException; +import im.tox.tox4j.core.exceptions.ToxConferencePeerQueryException; +import im.tox.tox4j.core.exceptions.ToxConferenceSendMessageException; +import im.tox.tox4j.core.exceptions.ToxConferenceSetMaxOfflineException; +import im.tox.tox4j.core.exceptions.ToxConferenceTitleException; import im.tox.tox4j.core.exceptions.ToxFileControlException; import im.tox.tox4j.core.exceptions.ToxFileGetException; import im.tox.tox4j.core.exceptions.ToxFileSeekException; @@ -13,72 +24,450 @@ import im.tox.tox4j.core.exceptions.ToxFriendGetPublicKeyException; import im.tox.tox4j.core.exceptions.ToxFriendSendMessageException; import im.tox.tox4j.core.exceptions.ToxGetPortException; +import im.tox.tox4j.core.exceptions.ToxGroupDisconnectException; +import im.tox.tox4j.core.exceptions.ToxGroupInviteAcceptException; +import im.tox.tox4j.core.exceptions.ToxGroupInviteFriendException; +import im.tox.tox4j.core.exceptions.ToxGroupIsConnectedException; +import im.tox.tox4j.core.exceptions.ToxGroupJoinException; +import im.tox.tox4j.core.exceptions.ToxGroupKickPeerException; +import im.tox.tox4j.core.exceptions.ToxGroupLeaveException; +import im.tox.tox4j.core.exceptions.ToxGroupNewException; +import im.tox.tox4j.core.exceptions.ToxGroupPeerQueryException; +import im.tox.tox4j.core.exceptions.ToxGroupReconnectException; +import im.tox.tox4j.core.exceptions.ToxGroupSelfNameSetException; +import im.tox.tox4j.core.exceptions.ToxGroupSelfQueryException; +import im.tox.tox4j.core.exceptions.ToxGroupSelfStatusSetException; +import im.tox.tox4j.core.exceptions.ToxGroupSendCustomPacketException; +import im.tox.tox4j.core.exceptions.ToxGroupSendCustomPrivatePacketException; +import im.tox.tox4j.core.exceptions.ToxGroupSendMessageException; +import im.tox.tox4j.core.exceptions.ToxGroupSendPrivateMessageException; +import im.tox.tox4j.core.exceptions.ToxGroupSetIgnoreException; +import im.tox.tox4j.core.exceptions.ToxGroupSetPasswordException; +import im.tox.tox4j.core.exceptions.ToxGroupSetPeerLimitException; +import im.tox.tox4j.core.exceptions.ToxGroupSetPrivacyStateException; +import im.tox.tox4j.core.exceptions.ToxGroupSetRoleException; +import im.tox.tox4j.core.exceptions.ToxGroupSetTopicLockException; +import im.tox.tox4j.core.exceptions.ToxGroupSetVoiceStateException; +import im.tox.tox4j.core.exceptions.ToxGroupStateQueryException; +import im.tox.tox4j.core.exceptions.ToxGroupTopicSetException; import im.tox.tox4j.core.exceptions.ToxNewException; import im.tox.tox4j.core.exceptions.ToxSetInfoException; import im.tox.tox4j.core.exceptions.ToxSetTypingException; @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, + 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) + throws ToxConferenceNewException; + // bool tox_conference_delete(Tox *tox, Tox_Conference_Number conference_number, Tox_Err_Conference_Delete *error); + static native void toxConferenceDelete(int instanceNumber, int conferenceNumber) + throws ToxConferenceDeleteException; + // 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; + + // Tox_Group_Number tox_group_new( + // Tox *tox, Tox_Group_Privacy_State privacy_state, + // const uint8_t group_name[], size_t group_name_length, + // const uint8_t name[], size_t name_length, Tox_Err_Group_New *error); + static native int toxGroupNew(int instanceNumber, int privacyState, byte[] groupName, byte[] name) + throws ToxGroupNewException; + // Tox_Group_Number tox_group_join( + // Tox *tox, const uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], + // const uint8_t name[], size_t name_length, + // const uint8_t password[], size_t password_length, + // Tox_Err_Group_Join *error); + static native int toxGroupJoin(int instanceNumber, byte[] chatId, byte[] name, byte[] password) + throws ToxGroupJoinException; + // bool tox_group_is_connected(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Is_Connected *error); + static native boolean toxGroupIsConnected(int instanceNumber, int groupNumber) + throws ToxGroupIsConnectedException; + // bool tox_group_disconnect(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Disconnect *error); + static native void toxGroupDisconnect(int instanceNumber, int groupNumber) + throws ToxGroupDisconnectException; + // bool tox_group_reconnect(Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Reconnect *error); + static native void toxGroupReconnect(int instanceNumber, int groupNumber) + throws ToxGroupReconnectException; + // bool tox_group_leave( + // Tox *tox, Tox_Group_Number group_number, + // const uint8_t part_message[], size_t length, + // Tox_Err_Group_Leave *error); + static native void toxGroupLeave(int instanceNumber, int groupNumber, byte[] partMessage) + throws ToxGroupLeaveException; + // bool tox_group_self_set_name( + // Tox *tox, Tox_Group_Number group_number, + // const uint8_t name[], size_t length, + // Tox_Err_Group_Self_Name_Set *error); + static native void toxGroupSelfSetName(int instanceNumber, int groupNumber, byte[] name) + throws ToxGroupSelfNameSetException; + // bool tox_group_self_get_name( + // const Tox *tox, Tox_Group_Number group_number, + // uint8_t name[], Tox_Err_Group_Self_Query *error); + static native byte[] toxGroupSelfGetName(int instanceNumber, int groupNumber) + throws ToxGroupSelfQueryException; + // bool tox_group_self_set_status(Tox *tox, Tox_Group_Number group_number, Tox_User_Status status, + // Tox_Err_Group_Self_Status_Set *error); + static native void toxGroupSelfSetStatus(int instanceNumber, int groupNumber, int status) + throws ToxGroupSelfStatusSetException; + // Tox_User_Status tox_group_self_get_status(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Self_Query *error); + static native int toxGroupSelfGetStatus(int instanceNumber, int groupNumber) + throws ToxGroupSelfQueryException; + // Tox_Group_Role tox_group_self_get_role(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Self_Query *error); + static native int toxGroupSelfGetRole(int instanceNumber, int groupNumber) + throws ToxGroupSelfQueryException; + // Tox_Group_Peer_Number tox_group_self_get_peer_id(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Self_Query *error); + static native int toxGroupSelfGetPeerId(int instanceNumber, int groupNumber) + throws ToxGroupSelfQueryException; + // bool tox_group_self_get_public_key(const Tox *tox, Tox_Group_Number group_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE], + // Tox_Err_Group_Self_Query *error); + static native byte[] toxGroupSelfGetPublicKey(int instanceNumber, int groupNumber) + throws ToxGroupSelfQueryException; + // bool tox_group_peer_get_name( + // const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, + // uint8_t name[], Tox_Err_Group_Peer_Query *error); + static native byte[] toxGroupPeerGetName(int instanceNumber, int groupNumber, int peerId) + throws ToxGroupPeerQueryException; + // Tox_User_Status tox_group_peer_get_status(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, + // Tox_Err_Group_Peer_Query *error); + static native int toxGroupPeerGetStatus(int instanceNumber, int groupNumber, int peerId) + throws ToxGroupPeerQueryException; + // Tox_Group_Role tox_group_peer_get_role(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, + // Tox_Err_Group_Peer_Query *error); + static native int toxGroupPeerGetRole(int instanceNumber, int groupNumber, int peerId) + throws ToxGroupPeerQueryException; + // Tox_Connection tox_group_peer_get_connection_status(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, + // Tox_Err_Group_Peer_Query *error); + static native int toxGroupPeerGetConnectionStatus(int instanceNumber, int groupNumber, int peerId) + throws ToxGroupPeerQueryException; + // bool tox_group_peer_get_public_key( + // const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, + // uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Group_Peer_Query *error); + static native byte[] toxGroupPeerGetPublicKey(int instanceNumber, int groupNumber, int peerId) + throws ToxGroupPeerQueryException; + // bool tox_group_set_topic( + // Tox *tox, Tox_Group_Number group_number, + // const uint8_t topic[], size_t length, + // Tox_Err_Group_Topic_Set *error); + static native void toxGroupSetTopic(int instanceNumber, int groupNumber, byte[] topic) + throws ToxGroupTopicSetException; + // bool tox_group_get_topic( + // const Tox *tox, Tox_Group_Number group_number, + // uint8_t topic[], Tox_Err_Group_State_Query *error); + static native byte[] toxGroupGetTopic(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // bool tox_group_get_name( + // const Tox *tox, Tox_Group_Number group_number, + // uint8_t name[], Tox_Err_Group_State_Query *error); + static native byte[] toxGroupGetName(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // bool tox_group_get_chat_id( + // const Tox *tox, Tox_Group_Number group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], + // Tox_Err_Group_State_Query *error); + static native byte[] toxGroupGetChatId(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, Tox_Group_Number group_number, + // Tox_Err_Group_State_Query *error); + static native int toxGroupGetPrivacyState(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, Tox_Group_Number group_number, + // Tox_Err_Group_State_Query *error); + static native int toxGroupGetVoiceState(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, Tox_Group_Number group_number, + // Tox_Err_Group_State_Query *error); + static native int toxGroupGetTopicLock(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // uint16_t tox_group_get_peer_limit(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Query *error); + static native int toxGroupGetPeerLimit(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // bool tox_group_get_password( + // const Tox *tox, Tox_Group_Number group_number, uint8_t password[], + // Tox_Err_Group_State_Query *error); + static native byte[] toxGroupGetPassword(int instanceNumber, int groupNumber) + throws ToxGroupStateQueryException; + // Tox_Group_Message_Id tox_group_send_message( + // const Tox *tox, Tox_Group_Number group_number, Tox_Message_Type message_type, + // const uint8_t message[], size_t length, + // Tox_Err_Group_Send_Message *error); + static native int toxGroupSendMessage(int instanceNumber, int groupNumber, int type, + byte[] message) throws ToxGroupSendMessageException; + // Tox_Group_Message_Id tox_group_send_private_message( + // const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type, + // const uint8_t message[], size_t length, + // Tox_Err_Group_Send_Private_Message *error); + static native int toxGroupSendPrivateMessage(int instanceNumber, int groupNumber, int peerId, + int type, byte[] message) throws ToxGroupSendPrivateMessageException; + // bool tox_group_send_custom_packet( + // const Tox *tox, Tox_Group_Number group_number, bool lossless, + // const uint8_t data[], size_t length, + // Tox_Err_Group_Send_Custom_Packet *error); + static native void toxGroupSendCustomPacket(int instanceNumber, int groupNumber, boolean lossless, + byte[] data) throws ToxGroupSendCustomPacketException; + // bool tox_group_send_custom_private_packet(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, bool lossless, + // const uint8_t data[], size_t length, + // Tox_Err_Group_Send_Custom_Private_Packet *error); + static native void toxGroupSendCustomPrivatePacket(int instanceNumber, int groupNumber, int peerId, + boolean lossless, byte[] data) throws ToxGroupSendCustomPrivatePacketException; + // bool tox_group_invite_friend( + // const Tox *tox, Tox_Group_Number group_number, Tox_Friend_Number friend_number, + // Tox_Err_Group_Invite_Friend *error); + static native void toxGroupInviteFriend(int instanceNumber, int groupNumber, int friendNumber) + throws ToxGroupInviteFriendException; + // Tox_Group_Number tox_group_invite_accept( + // Tox *tox, Tox_Friend_Number friend_number, + // const uint8_t invite_data[], size_t length, + // const uint8_t name[], size_t name_length, + // const uint8_t password[], size_t password_length, + // Tox_Err_Group_Invite_Accept *error); + static native int toxGroupInviteAccept(int instanceNumber, int friendNumber, byte[] inviteData, + byte[] name, byte[] password) throws ToxGroupInviteAcceptException; + // bool tox_group_set_password( + // Tox *tox, Tox_Group_Number group_number, + // const uint8_t password[], size_t length, + // Tox_Err_Group_Set_Password *error); + static native void toxGroupSetPassword(int instanceNumber, int groupNumber, byte[] password) + throws ToxGroupSetPasswordException; + // bool tox_group_set_topic_lock(Tox *tox, Tox_Group_Number group_number, Tox_Group_Topic_Lock topic_lock, + // Tox_Err_Group_Set_Topic_Lock *error); + static native void toxGroupSetTopicLock(int instanceNumber, int groupNumber, int topicLock) + throws ToxGroupSetTopicLockException; + // bool tox_group_set_voice_state(Tox *tox, Tox_Group_Number group_number, Tox_Group_Voice_State voice_state, + // Tox_Err_Group_Set_Voice_State *error); + static native void toxGroupSetVoiceState(int instanceNumber, int groupNumber, int voiceState) + throws ToxGroupSetVoiceStateException; + // bool tox_group_set_privacy_state(Tox *tox, Tox_Group_Number group_number, Tox_Group_Privacy_State privacy_state, + // Tox_Err_Group_Set_Privacy_State *error); + static native void toxGroupSetPrivacyState(int instanceNumber, int groupNumber, int privacyState) + throws ToxGroupSetPrivacyStateException; + // bool tox_group_set_peer_limit(Tox *tox, Tox_Group_Number group_number, uint16_t peer_limit, + // Tox_Err_Group_Set_Peer_Limit *error); + static native void toxGroupSetPeerLimit(int instanceNumber, int groupNumber, int peerLimit) + throws ToxGroupSetPeerLimitException; + // bool tox_group_set_ignore(Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, bool ignore, + // Tox_Err_Group_Set_Ignore *error); + static native void toxGroupSetIgnore(int instanceNumber, int groupNumber, int peerId, boolean ignore) + throws ToxGroupSetIgnoreException; + // bool tox_group_set_role(Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Group_Role role, + // Tox_Err_Group_Set_Role *error); + static native void toxGroupSetRole(int instanceNumber, int groupNumber, int peerId, int role) + throws ToxGroupSetRoleException; + // bool tox_group_kick_peer(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, + // Tox_Err_Group_Kick_Peer *error); + static native void toxGroupKickPeer(int instanceNumber, int groupNumber, int peerId) + throws ToxGroupKickPeerException; } diff --git a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCryptoImpl.kt b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCryptoImpl.kt index de4f23dcf..15676bf2d 100644 --- a/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCryptoImpl.kt +++ b/lib/src/jvmMain/java/im/tox/tox4j/impl/jni/ToxCryptoImpl.kt @@ -34,7 +34,8 @@ object ToxCryptoImpl : ToxCrypto { salt: ByteArray, ): PassKey = ToxCryptoJni.toxPassKeyDeriveWithSalt(passphrase, salt) - override fun passKeyDerive(passphrase: ByteArray): PassKey = ToxCryptoJni.toxPassKeyDerive(passphrase) + override fun passKeyDerive(passphrase: ByteArray): PassKey = + ToxCryptoJni.toxPassKeyDerive(passphrase) override fun decrypt( data: ByteArray, diff --git a/lib/src/jvmMain/proto/Core.proto b/lib/src/jvmMain/proto/Core.proto index 6c7e789b2..d261f0da8 100644 --- a/lib/src/jvmMain/proto/Core.proto +++ b/lib/src/jvmMain/proto/Core.proto @@ -36,7 +36,32 @@ message FileControl { } } +message ConferenceType { + enum Type { + TEXT = 0; + AV = 1; + } +} + +message GroupExitType { + enum Type { + QUIT = 0; + TIMEOUT = 1; + DISCONNECTED = 2; + SELF_DISCONNECTED = 3; + KICK = 4; + SYNC_ERROR = 5; + } +} +message GroupModEvent { + enum Type { + KICK = 0; + OBSERVER = 1; + USER = 2; + MODERATOR = 3; + } +} message SelfConnectionStatus { Connection.Type connection_status = 1; @@ -66,7 +91,6 @@ message FriendTyping { uint32 friend_number = 1; bool is_typing = 2; } - message FriendReadReceipt { uint32 friend_number = 1; uint32 message_id = 2; @@ -74,15 +98,13 @@ message FriendReadReceipt { message FriendRequest { bytes public_key = 1; - uint32 time_delta = 2; - bytes message = 3; + bytes message = 2; } message FriendMessage { uint32 friend_number = 1; - MessageType.Type type = 2; - uint32 time_delta = 3; - bytes message = 4; + MessageType.Type message_type = 2; + bytes message = 3; } message FileRecvControl { @@ -123,6 +145,163 @@ message FriendLosslessPacket { bytes data = 2; } +message ConferenceInvite { + uint32 friend_number = 1; + ConferenceType.Type type = 2; + bytes cookie = 3; +} + +message ConferenceConnected { + uint32 conference_number = 1; +} + +message ConferenceMessage { + uint32 conference_number = 1; + uint32 peer_number = 2; + MessageType.Type message_type = 3; + bytes message = 4; +} + +message ConferenceTitle { + uint32 conference_number = 1; + uint32 peer_number = 2; + bytes title = 3; +} + +message ConferencePeerName { + uint32 conference_number = 1; + uint32 peer_number = 2; + bytes name = 3; +} + +message ConferencePeerListChanged { + uint32 conference_number = 1; +} + +message GroupPeerName { + uint32 group_number = 1; + uint32 peer_id = 2; + bytes name = 3; +} + +message GroupPeerStatus { + uint32 group_number = 1; + uint32 peer_id = 2; + UserStatus.Type status = 3; +} + +message GroupTopic { + uint32 group_number = 1; + uint32 peer_id = 2; + bytes topic = 3; +} + +message GroupPrivacyState { + enum Type { + PUBLIC = 0; + PRIVATE = 1; + } + uint32 group_number = 1; + Type privacy_state = 2; +} + +message GroupVoiceState { + enum Type { + ALL = 0; + MODERATOR = 1; + FOUNDER = 2; + } + uint32 group_number = 1; + Type voice_state = 2; +} + +message GroupTopicLock { + enum Type { + ENABLED = 0; + DISABLED = 1; + } + uint32 group_number = 1; + Type topic_lock = 2; +} + +message GroupPeerLimit { + uint32 group_number = 1; + uint32 peer_limit = 2; +} + +message GroupPassword { + uint32 group_number = 1; + bytes password = 2; +} + +message GroupMessage { + uint32 group_number = 1; + uint32 peer_id = 2; + MessageType.Type message_type = 3; + bytes message = 4; + uint32 message_id = 5; +} + +message GroupPrivateMessage { + uint32 group_number = 1; + uint32 peer_id = 2; + MessageType.Type message_type = 3; + bytes message = 4; + uint32 message_id = 5; +} + +message GroupCustomPacket { + uint32 group_number = 1; + uint32 peer_id = 2; + bytes data = 3; +} + +message GroupCustomPrivatePacket { + uint32 group_number = 1; + uint32 peer_id = 2; + bytes data = 3; +} + +message GroupInvite { + uint32 friend_number = 1; + bytes invite_data = 2; + bytes group_name = 3; +} + +message GroupPeerJoin { + uint32 group_number = 1; + uint32 peer_id = 2; +} + +message GroupPeerExit { + uint32 group_number = 1; + uint32 peer_id = 2; + GroupExitType.Type exit_type = 3; + bytes name = 4; + bytes part_message = 5; +} + +message GroupSelfJoin { + uint32 group_number = 1; +} + +message GroupJoinFail { + enum Type { + PEER_LIMIT = 0; + INVALID_PASSWORD = 1; + UNKNOWN = 2; + } + uint32 group_number = 1; + Type fail_type = 2; +} + +message GroupModeration { + uint32 group_number = 1; + uint32 source_peer_id = 2; + uint32 target_peer_id = 3; + GroupModEvent.Type mod_type = 4; +} + message CoreEvents { repeated SelfConnectionStatus self_connection_status = 1; repeated FriendName friend_name = 2; @@ -139,4 +318,28 @@ message CoreEvents { repeated FileRecvChunk file_recv_chunk = 13; repeated FriendLossyPacket friend_lossy_packet = 14; repeated FriendLosslessPacket friend_lossless_packet = 15; + repeated ConferenceInvite conference_invite = 16; + repeated ConferenceConnected conference_connected = 17; + repeated ConferenceMessage conference_message = 18; + repeated ConferenceTitle conference_title = 19; + repeated ConferencePeerName conference_peer_name = 20; + repeated ConferencePeerListChanged conference_peer_list_changed = 21; + repeated GroupPeerName group_peer_name = 22; + repeated GroupPeerStatus group_peer_status = 23; + repeated GroupTopic group_topic = 24; + repeated GroupPrivacyState group_privacy_state = 25; + repeated GroupVoiceState group_voice_state = 26; + repeated GroupTopicLock group_topic_lock = 27; + repeated GroupPeerLimit group_peer_limit = 28; + repeated GroupPassword group_password = 29; + repeated GroupMessage group_message = 30; + repeated GroupPrivateMessage group_private_message = 31; + repeated GroupCustomPacket group_custom_packet = 32; + repeated GroupCustomPrivatePacket group_custom_private_packet = 33; + repeated GroupInvite group_invite = 34; + repeated GroupPeerJoin group_peer_join = 35; + repeated GroupPeerExit group_peer_exit = 36; + repeated GroupSelfJoin group_self_join = 37; + repeated GroupJoinFail group_join_fail = 38; + repeated GroupModeration group_moderation = 39; } diff --git a/lib/src/jvmTest/java/im/tox/tox4j/core/ToxCoreTest.kt b/lib/src/jvmTest/java/im/tox/tox4j/core/ToxCoreTest.kt index 7e6e62cf0..88a002168 100644 --- a/lib/src/jvmTest/java/im/tox/tox4j/core/ToxCoreTest.kt +++ b/lib/src/jvmTest/java/im/tox/tox4j/core/ToxCoreTest.kt @@ -44,7 +44,8 @@ class ToxCoreTest { } } - private suspend fun newToxCore(options: ToxOptions): ToxCore = Toxes.add { ToxCoreImpl(options) } + private suspend fun newToxCore(options: ToxOptions): ToxCore = + Toxes.add { ToxCoreImpl(options) } private fun runTox(block: suspend CoroutineScope.() -> Unit): Unit = runBlocking(Toxes()) { @@ -56,52 +57,50 @@ class ToxCoreTest { } @Test - fun bootstrap_withWrongHost_shouldFail() = - runTox { - val tox = newToxCore(ToxOptions()) - assertFailsWith { - tox.bootstrap("host-does-not-exist", tox.getUdpPort, tox.getDhtId) - } + fun bootstrap_withWrongHost_shouldFail() = runTox { + val tox = newToxCore(ToxOptions()) + assertFailsWith { + tox.bootstrap("host-does-not-exist", tox.getUdpPort, tox.getDhtId) } + } @Test - fun addFriendNorequest_shouldConnectTwoToxes() = - runTox { - val tox1 = newToxCore(ToxOptions()) - val tox2 = newToxCore(ToxOptions()) + fun addFriendNorequest_shouldConnectTwoToxes() = runTox { + val tox1 = newToxCore(ToxOptions()) + val tox2 = newToxCore(ToxOptions()) - tox2.bootstrap("localhost", tox1.getUdpPort, tox1.getDhtId) + tox2.bootstrap("localhost", tox1.getUdpPort, tox1.getDhtId) - tox1.addFriendNorequest(tox2.getPublicKey) - tox2.addFriendNorequest(tox1.getPublicKey) + tox1.addFriendNorequest(tox2.getPublicKey) + tox2.addFriendNorequest(tox1.getPublicKey) - var connected1 = false - var connected2 = false + var connected1 = false + var connected2 = false - while (!connected1 && !connected2) { - connected1 = - tox1.iterate( - object : ToxCoreEventListener { - override fun friendConnectionStatus( - friendNumber: ToxFriendNumber, - connectionStatus: ToxConnection, - state: Boolean, - ) = connectionStatus != ToxConnection.NONE - }, - connected1, - ) - connected2 = - tox2.iterate( - object : ToxCoreEventListener { - override fun friendConnectionStatus( - friendNumber: ToxFriendNumber, - connectionStatus: ToxConnection, - state: Boolean, - ) = connectionStatus != ToxConnection.NONE - }, - connected2, - ) - delay(tox1.iterationInterval.toLong()) - } + while (!connected1 && !connected2) { + connected1 = + tox1.iterate( + object : ToxCoreEventListener { + override fun friendConnectionStatus( + friendNumber: ToxFriendNumber, + connectionStatus: ToxConnection, + state: Boolean, + ) = connectionStatus != ToxConnection.NONE + }, + connected1, + ) + connected2 = + tox2.iterate( + object : ToxCoreEventListener { + override fun friendConnectionStatus( + friendNumber: ToxFriendNumber, + connectionStatus: ToxConnection, + state: Boolean, + ) = connectionStatus != ToxConnection.NONE + }, + connected2, + ) + delay(tox1.iterationInterval.toLong()) } + } }