Package org.linphone.core
Interface ChatMessage
public interface ChatMessage
An chat message is the object that is sent or received through a
.
To create a
either add text using
file informations using
file transfer must contain a type and subtype, the name of the file and it's
size. Finally call
To send files through a
transfer server URL with
side, either use
auto-download in the
, -1 disabling the feature and 0 always downloading files no matter it's size.
Keep in mind a
ChatRoom
.
To create a
ChatMessage
, use ChatRoom.createEmptyMessage()
, theneither add text using
addUtf8TextContent(java.lang.String)
or a Content
withfile informations using
addFileContent(org.linphone.core.Content)
. A valid Content
forfile transfer must contain a type and subtype, the name of the file and it's
size. Finally call
send()
to send it.To send files through a
ChatMessage
, you need to have configured a filetransfer server URL with
Core.setFileTransferServer(java.lang.String)
. On the receivingside, either use
downloadContent(org.linphone.core.Content)
to download received files or enableauto-download in the
Core
using Core.setMaxSizeForAutoDownloadIncomingFiles(int)
, -1 disabling the feature and 0 always downloading files no matter it's size.
Keep in mind a
ChatMessage
created by a {@link ChatRoom#Backend#Basic}ChatRoom
can only contain one Content
, either text or file. -
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
static enum
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContent
(Content content) Adds a content to the ChatMessage.void
addCustomHeader
(String headerName, String headerValue) Add custom headers to the message.void
addFileContent
(Content content) Adds a file content to the ChatMessage.void
addListener
(ChatMessageListener listener) void
addTextContent
(String text) Deprecated.01/07/2020.void
addUtf8TextContent
(String text) Creates aContent
of type PlainText with the given text as body.void
Cancel an ongoing file transfer attached to this message.createReaction
(String utf8Reaction) Creates a emoji reaction for the given chat mesage.boolean
downloadContent
(Content content) Linphone message has an app-specific field that can store a text.Gets the callId accociated with the message.Returns the chatroom this message belongs to.Content[]
Returns the list of contents in the message.Get the content type of a chat message.getCore()
Returns back pointer toCore
object.getCustomHeader
(String headerName) Retrieve a custom header value given its name.long
Returns the real time at which an ephemeral message expires and will be
deleted.long
Returns lifetime of an ephemeral message.Get full details about delivery error of a chat message.Linphone message can carry external body as defined by rfc2017.Get the file_transfer_information (used by call backs to recover informations
during a rcs file transfer)
Gets the forward info if available as a string.Get origin of the message.Returns the local address the message was sent or received with.Get the message identifier.long
Gets the native pointer used by this class to make native method calls.Returns our own reaction for a given chat message, if any.Gets the list of participants for which the imdn state has reached the
specified state and the time at which they did.Gets the list of reactions received for this chat message.Returns theChatMessage
this message is a reply to.Returns the ID of the message this is a reply to.Returns the address of the sender of the message this is a reply to.getState()
Get the state of the message.Deprecated.01/07/2020.long
getTime()
Get the time the message was sent.Get destination of the message.boolean
Get if a chat message is to be stored.Gets the object stored in this object user's dataGet text part of this message.boolean
Returns wether the chat message has a conference invitation content or not.boolean
Deprecated.27/10/2020.boolean
Returns wether the chat message is an ephemeral message or not.boolean
Deprecated.06/07/2020 check ifgetContents()
contains aContent
for whichContent.isFileTransfer()
returns true.boolean
Gets whether or not a file is currently being downloaded or uploaded.boolean
Returns wether the chat message is a forward message or not.boolean
Returns wehther the message has been sent or received.boolean
isRead()
Returns wether the message has been read or not.boolean
isReply()
Returns wether the chat message is a reply message or not.boolean
Get if the message was encrypted when transfered.boolean
isText()
Deprecated.int
putChar
(int character) Fulfill a chat message char by char.void
removeContent
(Content content) Removes a content from the ChatMessage.void
removeCustomHeader
(String headerName) Removes a custom header from the message.void
removeListener
(ChatMessageListener listener) void
send()
Send a chat message.void
setAppdata
(String data) Linphone message has an app-specific field that can store a text.void
setContentType
(String contentType) Set the content type of a chat message.void
setExternalBodyUrl
(String externalBodyUrl) Linphone message can carry external body as defined by rfc2017.void
setToBeStored
(boolean toBeStored) Set if a chat message is to be stored.void
setUserData
(Object data) Sets the object to store in this object user's dataint
setUtf8Text
(String text) Set a chat message text to be sent by linphone_chat_room_send_message.toString()
-
Method Details
-
getAppdata
Linphone message has an app-specific field that can store a text.
The application might want to use it for keeping data over restarts, like
thumbnail image path.- Returns:
- the application-specific data or null if none has been stored.
-
setAppdata
Linphone message has an app-specific field that can store a text.
The application might want to use it for keeping data over restarts, like
thumbnail image path.
Invoking this function will attempt to update the message storage to reflect
the change if it is enabled.- Parameters:
data
- the data to store into the message.
-
getCallId
Gets the callId accociated with the message.
- Returns:
- the call Id
-
getChatRoom
Returns the chatroom this message belongs to.
- Returns:
- the
ChatRoom
in which this message has been sent or received.
-
getContentType
Get the content type of a chat message.
- Returns:
- The content type of the chat message
-
setContentType
Set the content type of a chat message.
This content type must match a content that is text representable, such as
text/plain, text/html or image/svg+xml.- Parameters:
contentType
- The new content type of the chat message
-
getContents
Returns the list of contents in the message.
- Returns:
- The list of
Content
.
-
getCore
- Returns:
- the
Core
object associated with this message.
-
getEphemeralExpireTime
long getEphemeralExpireTime()- Returns:
- the time at which an ephemeral message expires. 0 means the message has
not been read.
-
getEphemeralLifetime
long getEphemeralLifetime()Returns lifetime of an ephemeral message.
The lifetime is the duration after which the ephemeral message will disappear
once viewed. see:isEphemeral()
- Returns:
- the lifetime of an ephemeral message, by default 0 (disabled).
-
getErrorInfo
Get full details about delivery error of a chat message.
- Returns:
- a
ErrorInfo
describing the details.
-
getExternalBodyUrl
Linphone message can carry external body as defined by rfc2017.
- Returns:
- external body url or null if not present.
-
setExternalBodyUrl
Linphone message can carry external body as defined by rfc2017.
- Parameters:
externalBodyUrl
- ex: access-type=URL; URL="http://www.foo.com/file"
-
getFileTransferInformation
Get the file_transfer_information (used by call backs to recover informations
during a rcs file transfer)
- Returns:
- a pointer to the
Content
structure or null if not present.
-
getForwardInfo
Gets the forward info if available as a string.
- Returns:
- the original sender of the message if it has been forwarded, null
otherwise.
-
getFromAddress
Get origin of the message.
- Returns:
- the
Address
of the sender.
-
isEphemeral
boolean isEphemeral()Returns wether the chat message is an ephemeral message or not.
An ephemeral message will automatically disappear from the recipient's screen
after the message has been viewed.- Returns:
- true if it is an ephemeral message, false otherwise
-
isFileTransfer
Deprecated.06/07/2020 check ifgetContents()
contains aContent
for whichContent.isFileTransfer()
returns true.Return whether or not a chat message is a file transfer.
- Returns:
- Whether or not the message is a file transfer
-
isFileTransferInProgress
boolean isFileTransferInProgress()Gets whether or not a file is currently being downloaded or uploaded.
- Returns:
- true if download or upload is in progress, false otherwise
-
isForward
boolean isForward()Returns wether the chat message is a forward message or not.
- Returns:
- true if it is a forward message, false otherwise
-
isOutgoing
boolean isOutgoing()Returns wehther the message has been sent or received.
- Returns:
- true if message has been sent, false if it has been received.
-
isRead
boolean isRead()Returns wether the message has been read or not.
- Returns:
- true if message has been marked as read, false otherwise.
-
isReply
boolean isReply()Returns wether the chat message is a reply message or not.
- Returns:
- true if it is a reply message, false otherwise
-
isSecured
boolean isSecured()Get if the message was encrypted when transfered.
- Returns:
- true if the message was encrypted when transfered, false otherwise.
-
isText
Deprecated.Return whether or not a chat message is a text.
- Returns:
- Whether or not the message is a text
-
getLocalAddress
Returns the local address the message was sent or received with.
- Returns:
- the
Address
of the local address used to send/receive this
message.
-
getMessageId
Get the message identifier.
It is used to identify a message so that it can be notified as delivered and/or
displayed.- Returns:
- The message identifier.
-
getOwnReaction
Returns our own reaction for a given chat message, if any.
- Returns:
- Our own
ChatMessageReaction
for that message if any, null
otherwise.
-
getReactions
Gets the list of reactions received for this chat message.
Warning: list is ordered by content of reaction message, not by received
timestamp!- Returns:
- The sorted list of reaction if any.
-
getReplyMessage
- Returns:
- the original message
ChatMessage
.
-
getReplyMessageId
Returns the ID of the message this is a reply to.
- Returns:
- the original message id.
-
getReplyMessageSenderAddress
Returns the address of the sender of the message this is a reply to.
- Returns:
- the original message sender
Address
.
-
getState
ChatMessage.State getState()Get the state of the message.
- Returns:
- the current
ChatMessage.State
of the message.
-
getTextContent
Deprecated.01/07/2020. UsegetUtf8Text()
instead.Gets the text content if available as a string.
- Returns:
- the
Content
buffer if available in System Locale, null
otherwise.
-
getTime
long getTime()Get the time the message was sent.
- Returns:
- the timestamp of when the message was sent.
-
getToAddress
Get destination of the message.
- Returns:
- the
Address
of the recipient.
-
getToBeStored
boolean getToBeStored()Get if a chat message is to be stored.
- Returns:
- Whether or not the message is to be stored
-
setToBeStored
void setToBeStored(boolean toBeStored) Set if a chat message is to be stored.
This content type must match a content that is text representable, such as
text/plain, text/html or image/svg+xml.- Parameters:
toBeStored
- Whether or not the chat message is to be stored
-
getUtf8Text
Get text part of this message.
Introduced in 01/07/2020- Returns:
- The text in UTF8 or null if no text.
-
setUtf8Text
Set a chat message text to be sent by linphone_chat_room_send_message.
Introduced in 01/07/2020- Parameters:
text
- The text in UTF8 to set.- Returns:
- 0 if succeed.
-
addContent
Adds a content to the ChatMessage.
- Parameters:
content
- theContent
object to add.
-
addCustomHeader
Add custom headers to the message.
- Parameters:
headerName
- name of the headerheaderValue
- header value
-
addFileContent
Adds a file content to the ChatMessage.
- Parameters:
content
- theContent
object to add.
-
addTextContent
Deprecated.01/07/2020. UseaddUtf8TextContent(java.lang.String)
instead.- Parameters:
text
- The text in System Locale to add to the message.
-
addUtf8TextContent
- Parameters:
text
- The text in UTF8 to add to the message.
-
cancelFileTransfer
void cancelFileTransfer()Cancel an ongoing file transfer attached to this message.
(upload or download) -
createReaction
- Parameters:
utf8Reaction
- the emoji character(s) as UTF-8.- Returns:
- a
ChatMessageReaction
object.
-
downloadContent
- Parameters:
content
- theContent
object to download (must have theContent.isFileTransfer()
method return true).- Returns:
- false if there is an error, true otherwise.
-
getCustomHeader
Retrieve a custom header value given its name.
- Parameters:
headerName
- header name searched- Returns:
- the custom header value or null if not found.
-
getParticipantsByImdnState
Gets the list of participants for which the imdn state has reached the
specified state and the time at which they did.
- Parameters:
state
- The LinphoneChatMessageState the imdn have reached (only use
LinphoneChatMessageStateDelivered, LinphoneChatMessageStateDeliveredToUser,
LinphoneChatMessageStateDisplayed and LinphoneChatMessageStateNotDelivered)- Returns:
- The list of participants.
-
hasConferenceInvitationContent
boolean hasConferenceInvitationContent()Returns wether the chat message has a conference invitation content or not.
- Returns:
- true if it has one, false otherwise.
-
hasTextContent
Deprecated.Returns wether the chat message has a text content or not.
- Returns:
- true if it has one, false otherwise.
-
putChar
int putChar(int character) Fulfill a chat message char by char.
Message linked to a Real Time Text Call send char in realtime following RFC
4103/T.140 To commit a message, use linphone_chat_room_send_message- Parameters:
character
- T.140 char- Returns:
- 0 if succeed.
-
removeContent
Removes a content from the ChatMessage.
- Parameters:
content
- theContent
object to remove.
-
removeCustomHeader
Removes a custom header from the message.
- Parameters:
headerName
- name of the header to remove
-
send
void send()Send a chat message.
-
addListener
-
removeListener
-
setUserData
Sets the object to store in this object user's data- Parameters:
data
- the object to store
-
getUserData
Object getUserData()Gets the object stored in this object user's data- Returns:
- the object store if any, null otherwise
-
getNativePointer
long getNativePointer()Gets the native pointer used by this class to make native method calls.- Returns:
- the nativer pointer, as long
-
toString
String toString()
-