Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ErrGetPort = ErrGetPortNotBound
- data ErrFriendCustomPacket
- data ErrConferenceGetType = ErrConferenceGetTypeConferenceNotFound
- data ErrConferenceTitle
- data ErrConferenceSendMessage
- data ErrConferenceJoin
- data ErrConferenceInvite
- data ErrConferencePeerQuery
- data ErrConferenceDelete = ErrConferenceDeleteConferenceNotFound
- data ErrConferenceNew = ErrConferenceNewInit
- data ErrFileSendChunk
- data ErrFileSend
- data ErrFileGet
- data ErrFileSeek
- data ErrFileControl
- data FileKind
- data ErrFriendSendMessage
- data ErrSetTyping = ErrSetTypingFriendNotFound
- data ErrFriendQuery
- data ErrFriendGetLastOnline = ErrFriendGetLastOnlineFriendNotFound
- data ErrFriendGetPublicKey = ErrFriendGetPublicKeyFriendNotFound
- data ErrFriendByPublicKey
- data ErrFriendDelete = ErrFriendDeleteFriendNotFound
- data ErrFriendAdd
- data ErrSetInfo
- data Connection
- data ErrBootstrap
- data ErrNew
- data LogLevel
- data SavedataType
- data ProxyType
- data MessageType
- type ToxPtr = Ptr ToxStruct
- tox_max_filename_length :: Word32
- tox_file_id_length :: Word32
- tox_hash_length :: Word32
- tox_max_custom_packet_size :: Word32
- tox_max_message_length :: Word32
- tox_max_friend_request_length :: Word32
- tox_max_status_message_length :: Word32
- tox_max_name_length :: Word32
- tox_address_size :: Word32
- tox_secret_key_size :: Word32
- tox_public_key_size :: Word32
- data ErrOptionsNew = ErrOptionsNewMalloc
- data Options = Options {}
- toxOptionsFree :: OptionsPtr -> IO ()
- tox_options_new :: CErr ErrOptionsNew -> IO OptionsPtr
- defaultOptions :: Options
- logLevelName :: LogLevel -> Char
- logHandler :: LogCb
- toxOptionsNew :: IO (Either ErrOptionsNew OptionsPtr)
- withToxOptions :: (OptionsPtr -> IO r) -> IO (Either ErrOptionsNew r)
- peekToxOptions :: OptionsPtr -> IO Options
- withOptions :: Options -> (OptionsPtr -> IO r) -> IO (Either ErrOptionsNew r)
- type PublicKey = FixedByteString 32
- newtype FixedByteString (size :: Nat) = FixedByteString ByteString
- tox_version_is_compatible :: Word32 -> Word32 -> Word32 -> Bool
- tox_version_patch :: Word32
- tox_version_minor :: Word32
- tox_version_major :: Word32
- data Events = Events [Event]
- data Event
- = SelfConnectionStatus { }
- | FriendRequest { }
- | FriendConnectionStatus { }
- | FriendLossyPacket { }
- | FriendLosslessPacket { }
- | FriendName {
- friendNumber :: Word32
- name :: ByteString
- | FriendStatus { }
- | FriendStatusMessage { }
- | FriendMessage { }
- | FriendReadReceipt { }
- | FriendTyping {
- friendNumber :: Word32
- typing :: Bool
- | FileChunkRequest {
- friendNumber :: Word32
- fileNumber :: Word32
- position :: Word64
- length :: Word16
- | FileRecv {
- friendNumber :: Word32
- fileNumber :: Word32
- kind :: Word32
- fileSize :: Word64
- filename :: ByteString
- | FileRecvChunk {
- friendNumber :: Word32
- fileNumber :: Word32
- position :: Word64
- data' :: ByteString
- | FileRecvControl { }
- | ConferenceInvite { }
- | ConferenceConnected { }
- | ConferencePeerListChanged { }
- | ConferencePeerName { }
- | ConferenceTitle { }
- | ConferenceMessage { }
- | GroupPeerName {
- groupNumber :: Word32
- peerId :: Word32
- name :: ByteString
- | GroupPeerStatus {
- groupNumber :: Word32
- peerId :: Word32
- status :: UserStatus
- | GroupTopic {
- groupNumber :: Word32
- peerId :: Word32
- topic :: ByteString
- | GroupPrivacyState { }
- | GroupVoiceState { }
- | GroupTopicLock { }
- | GroupPeerLimit {
- groupNumber :: Word32
- peerLimit :: Word32
- | GroupPassword { }
- | GroupMessage { }
- | GroupPrivateMessage { }
- | GroupCustomPacket {
- groupNumber :: Word32
- peerId :: Word32
- data' :: ByteString
- | GroupCustomPrivatePacket {
- groupNumber :: Word32
- peerId :: Word32
- data' :: ByteString
- | GroupInvite { }
- | GroupPeerJoin {
- groupNumber :: Word32
- peerId :: Word32
- | GroupPeerExit { }
- | GroupSelfJoin { }
- | GroupJoinFail { }
- | GroupModeration { }
- | DhtGetNodesResponse { }
- data ErrEventsIterate
- type ToxEvents = Ptr ToxEventsStruct
- data ToxEventsStruct
- tox_events_free :: ToxEvents -> IO ()
- tox_events_load :: CString -> Word32 -> IO ToxEvents
- tox_events_get_bytes :: ToxEvents -> CString -> IO ()
- tox_events_bytes_size :: ToxEvents -> IO Word32
- tox_events_iterate :: ToxPtr -> Bool -> CErr ErrEventsIterate -> IO ToxEvents
- tox_events_init :: ToxPtr -> IO ()
- withTox :: Options -> (ToxPtr -> IO a) -> IO (Either ErrNew a)
- toxGetSavedata :: ToxPtr -> IO ByteString
- toxBootstrap :: ToxPtr -> String -> Word16 -> ByteString -> IO (Either ErrBootstrap Bool)
- toxAddTcpRelay :: ToxPtr -> String -> Word16 -> ByteString -> IO (Either ErrBootstrap Bool)
- toxEventsToPtr :: [Event] -> IO ToxEvents
- toxEventsFromPtr :: ToxEvents -> IO (Either String [Event])
- toxEventsIterate :: ToxPtr -> IO (Either String [Event])
- toxIterationInterval :: ToxPtr -> IO Word32
- toxSelfGetAddress :: ToxPtr -> IO ByteString
- toxSelfSetNospam :: ToxPtr -> Word32 -> IO ()
- toxSelfGetNospam :: ToxPtr -> IO Word32
- toxSelfGetPublicKey :: ToxPtr -> IO ByteString
- toxSelfGetSecretKey :: ToxPtr -> IO ByteString
- toxSelfSetName :: ToxPtr -> ByteString -> IO (Either ErrSetInfo Bool)
- toxSelfGetName :: ToxPtr -> IO ByteString
- toxSelfSetStatusMessage :: ToxPtr -> ByteString -> IO (Either ErrSetInfo Bool)
- toxSelfGetStatusMessage :: ToxPtr -> IO ByteString
- toxSelfSetStatus :: ToxPtr -> UserStatus -> IO ()
- toxFriendAdd :: ToxPtr -> ByteString -> ByteString -> IO (Either ErrFriendAdd Word32)
- toxFriendAddNorequest :: ToxPtr -> ByteString -> IO (Either ErrFriendAdd Word32)
- toxFriendDelete :: ToxPtr -> Word32 -> IO (Either ErrFriendDelete Bool)
- toxFriendByPublicKey :: ToxPtr -> ByteString -> IO (Either ErrFriendByPublicKey Word32)
- toxFriendExists :: ToxPtr -> Word32 -> IO Bool
- toxSelfGetFriendList :: ToxPtr -> IO [Word32]
- toxFriendGetPublicKey :: ToxPtr -> Word32 -> IO (Either ErrFriendGetPublicKey ByteString)
- toxFriendGetLastOnline :: ToxPtr -> Word32 -> IO (Either ErrFriendGetLastOnline EpochTime)
- toxFriendGetName :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery ByteString)
- toxFriendGetStatusMessage :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery ByteString)
- toxFriendGetConnectionStatus :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery Connection)
- toxFriendGetTyping :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery Bool)
- toxSelfSetTyping :: ToxPtr -> Word32 -> Bool -> IO (Either ErrSetTyping Bool)
- toxFriendSendMessage :: ToxPtr -> Word32 -> MessageType -> ByteString -> IO (Either ErrFriendSendMessage Word32)
- toxHash :: ByteString -> IO ByteString
- toxFileControl :: ToxPtr -> Word32 -> Word32 -> FileControl -> IO (Either ErrFileControl Bool)
- toxFileSeek :: ToxPtr -> Word32 -> Word32 -> Word64 -> IO (Either ErrFileSeek Bool)
- toxFileGetFileId :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrFileGet ByteString)
- toxFileSend :: ToxPtr -> Word32 -> FileKind -> Word64 -> ByteString -> IO (Either ErrFileSend Word32)
- toxFileSendChunk :: ToxPtr -> Word32 -> Word32 -> Word64 -> ByteString -> IO (Either ErrFileSendChunk Bool)
- toxConferenceNew :: ToxPtr -> IO (Either ErrConferenceNew Word32)
- toxConferenceDelete :: ToxPtr -> Word32 -> IO (Either ErrConferenceDelete Bool)
- toxConferencePeerCount :: ToxPtr -> Word32 -> IO (Either ErrConferencePeerQuery Word32)
- toxConferencePeerGetName :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferencePeerQuery ByteString)
- toxConferencePeerGetPublicKey :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferencePeerQuery ByteString)
- toxConferencePeerNumberIsOurs :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferencePeerQuery Bool)
- toxConferenceInvite :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferenceInvite Bool)
- toxConferenceJoin :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrConferenceJoin Word32)
- toxConferenceSendMessage :: ToxPtr -> Word32 -> MessageType -> ByteString -> IO (Either ErrConferenceSendMessage Bool)
- toxConferenceGetTitle :: ToxPtr -> Word32 -> IO (Either ErrConferenceTitle ByteString)
- toxConferenceSetTitle :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrConferenceTitle Bool)
- toxConferenceGetChatlist :: ToxPtr -> IO [Word32]
- toxConferenceGetType :: ToxPtr -> Word32 -> IO (Either ErrConferenceGetType ConferenceType)
- toxFriendLossyPacket :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrFriendCustomPacket Bool)
- toxFriendLosslessPacket :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrFriendCustomPacket Bool)
- toxSelfGetDhtId :: ToxPtr -> IO ByteString
- toxSelfGetUdpPort :: ToxPtr -> IO (Either ErrGetPort Word16)
- toxSelfGetTcpPort :: ToxPtr -> IO (Either ErrGetPort Word16)
Documentation
data ErrGetPort Source #
Instances
data ErrFriendCustomPacket Source #
Instances
data ErrConferenceGetType Source #
Instances
data ErrConferenceTitle Source #
Instances
data ErrConferenceSendMessage Source #
ErrConferenceSendMessageConferenceNotFound | |
ErrConferenceSendMessageTooLong | |
ErrConferenceSendMessageNoConnection | |
ErrConferenceSendMessageFailSend |
Instances
data ErrConferenceJoin Source #
ErrConferenceJoinInvalidLength | |
ErrConferenceJoinWrongType | |
ErrConferenceJoinFriendNotFound | |
ErrConferenceJoinDuplicate | |
ErrConferenceJoinInitFail | |
ErrConferenceJoinFailSend |
Instances
data ErrConferenceInvite Source #
Instances
data ErrConferencePeerQuery Source #
ErrConferencePeerQueryConferenceNotFound | |
ErrConferencePeerQueryPeerNotFound | |
ErrConferencePeerQueryNoConnection |
Instances
data ErrConferenceDelete Source #
Instances
data ErrConferenceNew Source #
Instances
data ErrFileSendChunk Source #
Instances
data ErrFileSend Source #
ErrFileSendNull | |
ErrFileSendFriendNotFound | |
ErrFileSendFriendNotConnected | |
ErrFileSendNameTooLong | |
ErrFileSendTooMany |
Instances
data ErrFileGet Source #
Instances
data ErrFileSeek Source #
ErrFileSeekFriendNotFound | |
ErrFileSeekFriendNotConnected | |
ErrFileSeekNotFound | |
ErrFileSeekDenied | |
ErrFileSeekInvalidPosition | |
ErrFileSeekSendq |
Instances
data ErrFileControl Source #
ErrFileControlFriendNotFound | |
ErrFileControlFriendNotConnected | |
ErrFileControlNotFound | |
ErrFileControlNotPaused | |
ErrFileControlDenied | |
ErrFileControlAlreadyPaused | |
ErrFileControlSendq |
Instances
Instances
Bounded FileKind Source # | |
Enum FileKind Source # | |
Eq FileKind Source # | |
Ord FileKind Source # | |
Defined in FFI.Tox.Tox | |
Read FileKind Source # | |
Show FileKind Source # | |
Generic FileKind Source # | |
Arbitrary FileKind Source # | |
MessagePack FileKind Source # | |
Defined in FFI.Tox.Tox toObject :: Config -> FileKind -> Object # fromObjectWith :: (Applicative m, Monad m, MonadValidate DecodeError m) => Config -> Object -> m FileKind # | |
type Rep FileKind Source # | |
data ErrFriendSendMessage Source #
ErrFriendSendMessageNull | |
ErrFriendSendMessageFriendNotFound | |
ErrFriendSendMessageFriendNotConnected | |
ErrFriendSendMessageSendq | |
ErrFriendSendMessageTooLong | |
ErrFriendSendMessageEmpty |
Instances
data ErrSetTyping Source #
Instances
data ErrFriendQuery Source #
Instances
data ErrFriendGetLastOnline Source #
Instances
data ErrFriendGetPublicKey Source #
Instances
data ErrFriendByPublicKey Source #
Instances
data ErrFriendDelete Source #
Instances
data ErrFriendAdd Source #
ErrFriendAddNull | |
ErrFriendAddTooLong | |
ErrFriendAddNoMessage | |
ErrFriendAddOwnKey | |
ErrFriendAddAlreadySent | |
ErrFriendAddBadChecksum | |
ErrFriendAddSetNewNospam | |
ErrFriendAddMalloc |
Instances
data ErrSetInfo Source #
Instances
data Connection Source #
Instances
data ErrBootstrap Source #
Instances
ErrNewNull | |
ErrNewMalloc | |
ErrNewPortAlloc | |
ErrNewProxyBadType | |
ErrNewProxyBadHost | |
ErrNewProxyBadPort | |
ErrNewProxyNotFound | |
ErrNewLoadEncrypted | |
ErrNewLoadBadFormat |
Instances
Instances
Bounded LogLevel Source # | |
Enum LogLevel Source # | |
Eq LogLevel Source # | |
Ord LogLevel Source # | |
Defined in FFI.Tox.Tox | |
Read LogLevel Source # | |
Show LogLevel Source # | |
Generic LogLevel Source # | |
Arbitrary LogLevel Source # | |
MessagePack LogLevel Source # | |
Defined in FFI.Tox.Tox toObject :: Config -> LogLevel -> Object # fromObjectWith :: (Applicative m, Monad m, MonadValidate DecodeError m) => Config -> Object -> m LogLevel # | |
type Rep LogLevel Source # | |
Defined in FFI.Tox.Tox type Rep LogLevel = D1 ('MetaData "LogLevel" "FFI.Tox.Tox" "toxcore-c-0.2.12-inplace" 'False) ((C1 ('MetaCons "LogLevelTrace" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LogLevelDebug" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LogLevelInfo" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LogLevelWarning" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LogLevelError" 'PrefixI 'False) (U1 :: Type -> Type)))) |
data SavedataType Source #
Instances
Instances
data MessageType Source #
Instances
tox_max_filename_length :: Word32 Source #
Maximum file name length for file transfers.
tox_file_id_length :: Word32 Source #
The number of bytes in a file id.
tox_hash_length :: Word32 Source #
The number of bytes in a hash generated by tox_hash.
tox_max_custom_packet_size :: Word32 Source #
Maximum size of custom packets. TODO: should be LENGTH?
tox_max_message_length :: Word32 Source #
Maximum length of a single message after which it should be split.
tox_max_friend_request_length :: Word32 Source #
Maximum length of a friend request message in bytes.
tox_max_status_message_length :: Word32 Source #
Maximum length of a status message in bytes.
tox_max_name_length :: Word32 Source #
Maximum length of a nickname in bytes.
tox_address_size :: Word32 Source #
The size of a Tox address in bytes. Tox addresses are in the format
[Public Key (tox_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 even bytes (0, 2, 4, ...), the second byte is an XOR of all the odd bytes (1, 3, 5, ...) of the Public Key and nospam.
tox_secret_key_size :: Word32 Source #
The size of a Tox Secret Key in bytes.
tox_public_key_size :: Word32 Source #
The size of a Tox Public Key in bytes.
data ErrOptionsNew Source #
Instances
Options | |
|
Instances
toxOptionsFree :: OptionsPtr -> IO () Source #
Releases all resources associated with an options objects.
Passing a pointer that was not returned by tox_options_new results in undefined behaviour.
tox_options_new :: CErr ErrOptionsNew -> IO OptionsPtr Source #
Allocates a new Tox_Options object and initialises it with the default options. This function can be used to preserve long term ABI compatibility by giving the responsibility of allocation and deallocation to the Tox library.
Objects returned from this function must be freed using the tox_options_free function.
@return A new OptionsPtr
with default options or nullPtr
on failure.
logLevelName :: LogLevel -> Char Source #
logHandler :: LogCb Source #
withToxOptions :: (OptionsPtr -> IO r) -> IO (Either ErrOptionsNew r) Source #
peekToxOptions :: OptionsPtr -> IO Options Source #
Read Options
from an OptionsPtr
.
If the passed pointer is nullPtr
, the behaviour is undefined.
withOptions :: Options -> (OptionsPtr -> IO r) -> IO (Either ErrOptionsNew r) Source #
Allocate a new C options pointer, fills in the values from Options
,
calls the processor function, and deallocates the options pointer.
The OptionsPtr
passed to the processor function is never nullPtr
. If
allocation fails, the IO action evaluates to Left
with an appropriate
error code.
type PublicKey = FixedByteString 32 Source #
newtype FixedByteString (size :: Nat) Source #
Instances
tox_version_is_compatible :: Word32 -> Word32 -> Word32 -> Bool Source #
Return whether the compiled library version is compatible with the passed version numbers.
tox_version_patch :: Word32 Source #
The patch or revision number. Incremented when bugfixes are applied without changing any functionality or API or ABI.
tox_version_minor :: Word32 Source #
The minor version number. Incremented when functionality is added without breaking the API or ABI. Set to 0 when the major version number is incremented.
tox_version_major :: Word32 Source #
The major version number. Incremented when the API or ABI changes in an incompatible way.
Instances
Eq Events Source # | |
Ord Events Source # | |
Show Events Source # | |
Generic Events Source # | |
Arbitrary Events Source # | |
MessagePack Events Source # | |
Defined in Network.Tox.Types.Events toObject :: Config -> Events -> Object # fromObjectWith :: (Applicative m, Monad m, MonadValidate DecodeError m) => Config -> Object -> m Events # | |
type Rep Events Source # | |
Defined in Network.Tox.Types.Events |
Instances
data ErrEventsIterate Source #
Common error codes for all functions that set a piece of user-visible client information.
Instances
type ToxEvents = Ptr ToxEventsStruct Source #
data ToxEventsStruct Source #
tox_events_free :: ToxEvents -> IO () Source #
tox_events_iterate :: ToxPtr -> Bool -> CErr ErrEventsIterate -> IO ToxEvents Source #
tox_events_init :: ToxPtr -> IO () Source #
toxGetSavedata :: ToxPtr -> IO ByteString Source #
toxBootstrap :: ToxPtr -> String -> Word16 -> ByteString -> IO (Either ErrBootstrap Bool) Source #
Sends a "get nodes" request to the given bootstrap node with IP, port, and public key to setup connections.
This function will attempt to connect to the node using UDP. You must use this function even if Options.udp_enabled was set to false.
param address The hostname or IP address (IPv4 or IPv6) of the node.
param port The port on the host on which the bootstrap Tox instance is
listening.
param public_key The long term public key of the bootstrap node
(
return true on success.tox_public_key_size
bytes).
toxAddTcpRelay :: ToxPtr -> String -> Word16 -> ByteString -> IO (Either ErrBootstrap Bool) Source #
Adds additional host:port pair as TCP relay.
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 IP address (IPv4 or IPv6) of the TCP relay.
param port The port on the host on which the TCP relay is listening.
param public_key The long term public key of the TCP relay
(
return true on success.tox_public_key_size
bytes).
toxIterationInterval :: ToxPtr -> IO Word32 Source #
Return the time in milliseconds before tox_iterate() should be called again for optimal performance.
toxSelfGetAddress :: ToxPtr -> IO ByteString Source #
Writes the Tox friend address of the client to a byte array. The address is not in human-readable format. If a client wants to display the address, formatting is required.
param address A memory region of at least
see tox_address_size
bytes. If this
parameter is nullPtr
, this function has no effect.
tox_address_size
for the address format.
toxSelfSetNospam :: ToxPtr -> Word32 -> IO () Source #
Set the 4-byte nospam part of the address.
@param nospam Any 32 bit unsigned integer.
toxSelfGetPublicKey :: ToxPtr -> IO ByteString Source #
Copy the Tox Public Key (long term) from the Tox object.
@param public_key A memory region of at least tox_public_key_size
bytes. If
this parameter is nullPtr
, this function has no effect.
toxSelfGetSecretKey :: ToxPtr -> IO ByteString Source #
Copy the Tox Secret Key from the Tox object.
@param secret_key A memory region of at least tox_secret_key_size
bytes. If
this parameter is nullPtr
, this function has no effect.
toxSelfSetName :: ToxPtr -> ByteString -> IO (Either ErrSetInfo Bool) Source #
Set the nickname for the Tox client.
Nickname length cannot exceed tox_max_name_length
. If length is 0, the name
parameter is ignored (it can be nullPtr
), and the nickname is set back to
empty.
param name A byte array containing the new nickname.
param length The size of the name byte array.
@return true on success.
toxSelfGetName :: ToxPtr -> IO ByteString Source #
Write the nickname set by tox_self_set_name to a byte array.
If no nickname was set before calling this function, the name is empty, and this function has no effect.
Call tox_self_get_name_size to find out how much memory to allocate for the result.
@param name A valid memory location large enough to hold the nickname. If this parameter is NULL, the function has no effect.
toxSelfSetStatusMessage :: ToxPtr -> ByteString -> IO (Either ErrSetInfo Bool) Source #
Set the client's status message.
Status message length cannot exceed tox_max_status_message_length
. If
length is 0, the status parameter is ignored (it can be nullPtr
), and the
user status is set back to empty.
toxSelfGetStatusMessage :: ToxPtr -> IO ByteString Source #
Write the status message set by tox_self_set_status_message to a byte array.
If no status message was set before calling this function, the status is empty, and this function has no effect.
Call tox_self_get_status_message_size to find out how much memory to allocate for the result.
@param status_message A valid memory location large enough to hold the status message. If this parameter is NULL, the function has no effect.
toxSelfSetStatus :: ToxPtr -> UserStatus -> IO () Source #
Set the client's user status.
@param user_status One of the user statuses listed in the enumeration above.
toxFriendAdd :: ToxPtr -> ByteString -> ByteString -> IO (Either ErrFriendAdd Word32) Source #
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
tox_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.
If more than INT32_MAX friends are added, this function causes undefined behaviour.
param address The address of the friend (returned by tox_self_get_address of
the friend you wish to add) it must be
param message The message that will be sent along with the friend request.
@param length The length of the data byte array.tox_address_size
bytes.
@return the friend number on success, UINT32_MAX on failure.
toxFriendAddNorequest :: ToxPtr -> ByteString -> IO (Either ErrFriendAdd Word32) Source #
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 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 public_key A byte array of length tox_public_key_size
containing the
Public Key (not the Address) of the friend to add.
return the friend number on success, UINT32_MAX on failure.
see tox_friend_add for a more detailed description of friend numbers.
toxFriendDelete :: ToxPtr -> Word32 -> IO (Either ErrFriendDelete Bool) Source #
Remove a friend from the friend list.
This does not notify the friend of their deletion. After calling this function, this client will appear offline to the friend and no communication can occur between the two.
@param friend_number Friend number for the friend to be deleted.
@return true on success.
toxFriendByPublicKey :: ToxPtr -> ByteString -> IO (Either ErrFriendByPublicKey Word32) Source #
Return the friend number associated with that Public Key.
return the friend number on success, UINT32_MAX on failure.
param public_key A byte array containing the Public Key.
toxFriendExists :: ToxPtr -> Word32 -> IO Bool Source #
Checks if a friend with the given friend number exists and returns true if it does.
toxSelfGetFriendList :: ToxPtr -> IO [Word32] Source #
Copy a list of valid friend numbers into an array.
Call tox_self_get_friend_list_size to determine the number of elements to allocate.
@param list A memory region with enough space to hold the friend list. If
this parameter is nullPtr
, this function has no effect.
toxFriendGetPublicKey :: ToxPtr -> Word32 -> IO (Either ErrFriendGetPublicKey ByteString) Source #
Copies the Public Key associated with a given friend number to a byte array.
param friend_number The friend number you want the Public Key of.
param public_key A memory region of at least tox_public_key_size
bytes. If
this parameter is nullPtr
, this function has no effect.
@return true on success.
toxFriendGetLastOnline :: ToxPtr -> Word32 -> IO (Either ErrFriendGetLastOnline EpochTime) Source #
Return a unix-time timestamp of the last time the friend associated with a given friend number was seen online. This function will return UINT64_MAX on error.
@param friend_number The friend number you want to query.
toxFriendGetName :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery ByteString) Source #
Write the name of the friend designated by the given friend number to a byte array.
Call tox_friend_get_name_size to determine the allocation size for the name
parameter.
The data written to name
is equal to the data received by the last
friend_name
callback.
@param name A valid memory region large enough to store the friend's name.
@return true on success.
toxFriendGetStatusMessage :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery ByteString) Source #
Write the status message of the friend designated by the given friend number to a byte array.
Call tox_friend_get_status_message_size to determine the allocation size for the status_name
parameter.
The data written to status_message
is equal to the data received by the last
friend_status_message
callback.
@param status_message A valid memory region large enough to store the friend's status message.
toxFriendGetConnectionStatus :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery Connection) Source #
Check whether a friend is currently connected to this client.
The result of this function is equal to the last value received by the
friend_connection_status
callback.
@param friend_number The friend number for which to query the connection status.
@return the friend's connection status as it was received through the
friend_connection_status
event.
toxFriendGetTyping :: ToxPtr -> Word32 -> IO (Either ErrFriendQuery Bool) Source #
Check whether a friend is currently typing a message.
@param friend_number The friend number for which to query the typing status.
return true if the friend is typing.
return false if the friend is not typing, or the friend number was
invalid. Inspect the error code to determine which case it is.
toxSelfSetTyping :: ToxPtr -> Word32 -> Bool -> IO (Either ErrSetTyping Bool) Source #
Set the client's typing status for a friend.
The client is responsible for turning it on or off.
param friend_number The friend to which the client is typing a message.
param typing The typing status. True means the client is typing.
@return true on success.
toxFriendSendMessage :: ToxPtr -> Word32 -> MessageType -> ByteString -> IO (Either ErrFriendSendMessage Word32) Source #
Send a text chat message to an online friend.
This function creates a chat message packet and pushes it into the send queue.
The message length may not exceed tox_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 friend_read_receipt
event will be passed this
message ID.
Message IDs are unique per friend. The first message ID is 0. Message IDs are incremented by 1 each time a message is sent. If UINT32_MAX messages were sent, the next message ID is 0.
param type Message type (normal, action, ...).
param friend_number The friend number of the friend to send the message to.
param message A non-
param length Length of the message to be sent.nullPtr
pointer to the first element of a byte array
containing the message text.
toxHash :: ByteString -> IO ByteString Source #
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.
If hash is nullPtr
or data is nullPtr
while length is not 0 the function
returns false, otherwise it returns true.
This function is a wrapper to internal message-digest functions.
param hash A valid memory location the hash data. It must be at least
param data Data to be hashed or tox_hash_length
bytes in size.
nullPtr
.
@param length Size of the data array or 0.
@return true if hash was not nullPtr
.
toxFileControl :: ToxPtr -> Word32 -> Word32 -> FileControl -> IO (Either ErrFileControl Bool) Source #
Sends a file control command to a friend for a given file transfer.
param friend_number The friend number of the friend the file is being
transferred to or received from.
param file_number The friend-specific identifier for the file transfer.
@param control The control command to send.
@return true on success.
toxFileSeek :: ToxPtr -> Word32 -> Word32 -> Word64 -> IO (Either ErrFileSeek Bool) Source #
Sends a file seek control command to a friend for a given file transfer.
This function can only be called to resume a file transfer right before FileControlResume is sent.
param friend_number The friend number of the friend the file is being
received from.
param file_number The friend-specific identifier for the file transfer.
@param position The position that the file should be seeked to.
toxFileGetFileId :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrFileGet ByteString) Source #
Copy the file id associated to the file transfer to a byte array.
param friend_number The friend number of the friend the file is being
transferred to or received from.
param file_number The friend-specific identifier for the file transfer.
@param file_id A memory region of at least tox_file_id_length
bytes. If
this parameter is nullPtr
, this function has no effect.
@return true on success.
toxFileSend :: ToxPtr -> Word32 -> FileKind -> Word64 -> ByteString -> IO (Either ErrFileSend Word32) Source #
Send a file transmission request.
Maximum filename length is tox_max_filename_length
bytes. The filename
should generally just be a file name, not a path with directory names.
If a non-UINT64_MAX file size is provided, it can be used by both sides to determine the sending progress. File size can be set to UINT64_MAX for streaming data of unknown size.
File transmission occurs in chunks, which are requested through the
file_chunk_request
event.
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 determines the file size.
- If the file size was increased
- and sending mode was streaming (file_size = UINT64_MAX), the behaviour will be as expected.
- and sending mode was file (file_size != UINT64_MAX), the file_chunk_request callback will receive length = 0 when Core thinks the file transfer has finished. If the client remembers the file size as it was when sending the request, it will terminate the transfer normally. If the client re-reads the size, it will think the friend cancelled the transfer.
- If the file size was decreased
- and sending mode was streaming, the behaviour is as expected.
- and sending mode was file, the callback will return 0 at the new (earlier) end-of-file, signalling to the friend that the transfer was cancelled.
- If the file contents were modified
- at a position before the current read, the two files (local and remote) will differ after the transfer terminates.
- at a position after the current read, the file transfer will succeed as expected.
- In either case, both sides will regard the transfer as complete and successful.
param friend_number 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 file_size Size in bytes of the file the client wants to send,
UINT64_MAX if unknown or streaming.
param file_id A file identifier of length tox_file_id_length
that can be
used to uniquely identify file transfers across core restarts. If
nullPtr
, a random one will be generated by core. It can then be obtained
by using tox_file_get_file_id().
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.
param filename_length Size in bytes of the filename.
@return A file number used as an identifier in subsequent callbacks. This number is per friend. File numbers are reused after a transfer terminates. On failure, this function returns UINT32_MAX. Any pattern in file numbers should not be relied on.
toxFileSendChunk :: ToxPtr -> Word32 -> Word32 -> Word64 -> ByteString -> IO (Either ErrFileSendChunk Bool) Source #
Send a chunk of file data to a friend.
This function is called in response to the file_chunk_request
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.
param friend_number The friend number of the receiving friend for this file.
param file_number The file transfer identifier returned by tox_file_send.
param position The file or stream position from which to continue reading.
return true on success.
toxConferenceNew :: ToxPtr -> IO (Either ErrConferenceNew Word32) Source #
Creates a new conference.
This function creates a new text conference.
@return conference number on success, or UINT32_MAX on failure.
toxConferenceDelete :: ToxPtr -> Word32 -> IO (Either ErrConferenceDelete Bool) Source #
This function deletes a conference.
@param conference_number The conference number of the conference to be deleted.
@return true on success.
toxConferencePeerCount :: ToxPtr -> Word32 -> IO (Either ErrConferencePeerQuery Word32) Source #
Return the number of peers in the conference. Return value is unspecified on failure.
toxConferencePeerGetName :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferencePeerQuery ByteString) Source #
Copy the name of peer_number who is in conference_number to name. name must be at least TOX_MAX_NAME_LENGTH long.
@return true on success.
toxConferencePeerGetPublicKey :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferencePeerQuery ByteString) Source #
Copy the public key of peer_number who is in conference_number to public_key. public_key must be TOX_PUBLIC_KEY_SIZE long.
@return true on success.
toxConferencePeerNumberIsOurs :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferencePeerQuery Bool) Source #
Return true if passed peer_number corresponds to our own.
toxConferenceInvite :: ToxPtr -> Word32 -> Word32 -> IO (Either ErrConferenceInvite Bool) Source #
Invites a friend to a conference.
param friend_number The friend number of the friend we want to invite.
param conference_number The conference number of the conference we want to invite the friend to.
@return true on success.
toxConferenceJoin :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrConferenceJoin Word32) Source #
Joins a conference that the client has been invited to.
param friend_number The friend number of the friend who sent the invite.
param cookie Received via the conference_invite
event.
@param length The size of cookie.
@return conference number on success, UINT32_MAX on failure.
toxConferenceSendMessage :: ToxPtr -> Word32 -> MessageType -> ByteString -> IO (Either ErrConferenceSendMessage Bool) Source #
Send a text chat message to the conference.
This function creates a conference message packet and pushes it into the send queue.
The message length may not exceed TOX_MAX_MESSAGE_LENGTH. Larger messages must be split by the client and sent as separate messages. Other clients can then reassemble the fragments.
param conference_number The conference number of the conference the message is intended for.
param type Message type (normal, action, ...).
param message A non-NULL pointer to the first element of a byte array
containing the message text.
param length Length of the message to be sent.
@return true on success.
toxConferenceGetTitle :: ToxPtr -> Word32 -> IO (Either ErrConferenceTitle ByteString) Source #
Write the title designated by the given conference number to a byte array.
Call tox_conference_get_title_size to determine the allocation size for the title
parameter.
The data written to title
is equal to the data received by the last
conference_title
callback.
@param title A valid memory region large enough to store the title. If this parameter is NULL, this function has no effect.
@return true on success.
toxConferenceSetTitle :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrConferenceTitle Bool) Source #
Set the conference title and broadcast it to the rest of the conference.
Title length cannot be longer than TOX_MAX_NAME_LENGTH.
@return true on success.
toxConferenceGetChatlist :: ToxPtr -> IO [Word32] Source #
Copy a list of valid conference IDs into the array chatlist. Determine how much space
to allocate for the array with the tox_conference_get_chatlist_size
function.
toxConferenceGetType :: ToxPtr -> Word32 -> IO (Either ErrConferenceGetType ConferenceType) Source #
toxFriendLossyPacket :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrFriendCustomPacket Bool) Source #
Send a custom lossy packet to a friend.
The first byte of data must be in the range 200-254. Maximum length of a
custom packet is tox_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.
Unless latency is an issue, it is recommended that you use lossless custom packets instead.
param friend_number The friend number of the friend this lossy packet
should be sent to.
param data A byte array containing the packet data.
@param length The length of the packet data byte array.
@return true on success.
toxFriendLosslessPacket :: ToxPtr -> Word32 -> ByteString -> IO (Either ErrFriendCustomPacket Bool) Source #
Send a custom lossless packet to a friend.
The first byte of data must be in the range 160-191. Maximum length of a
custom packet is tox_max_custom_packet_size
.
Lossless packet behaviour is comparable to TCP (reliability, arrive in order) but with packets instead of a stream.
param friend_number The friend number of the friend this lossless packet
should be sent to.
param data A byte array containing the packet data.
@param length The length of the packet data byte array.
@return true on success.
toxSelfGetDhtId :: ToxPtr -> IO ByteString Source #
Writes the temporary DHT public key of this instance to a byte array.
This can be used in combination with an externally accessible IP address and the bound port (from tox_self_get_udp_port) to run a temporary bootstrap node.
Be aware that every time a new instance is created, the DHT public key changes, meaning this cannot be used to run a permanent bootstrap node.
@param dht_id A memory region of at least tox_public_key_size
bytes. If
this parameter is nullPtr
, this function has no effect.
toxSelfGetUdpPort :: ToxPtr -> IO (Either ErrGetPort Word16) Source #
Return the UDP port this Tox instance is bound to.
toxSelfGetTcpPort :: ToxPtr -> IO (Either ErrGetPort Word16) Source #
Return the TCP port this Tox instance is bound to. This is only relevant if the instance is acting as a TCP relay.