Package org.linphone.core
Interface ChatMessage
public interface ChatMessage
A
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
ChatMessage
represents an instant message that can be send orreceived through 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
Nested ClassesModifier 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) Adds 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 text/plain with the provided string, and
attach it to the message.void
Cancels an ongoing file transfer attached to this message (upload or download).createReaction
(String utf8Reaction) Creates a emoji reaction for the given chat mesage.boolean
downloadContent
(Content content) boolean
Starts the download of all theContent
objects representing file
transfers included in the message (Content.isFileTransfer()
method
returns true).Linphone message has an app-specific field that can store a text.Gets the SIP call-id accociated with the message.Returns the chatroom this message belongs to.Content[]
Returns the list of contents in the message.Gets the content type of a chat message.getCore()
Returns back pointer toCore
object.getCustomHeader
(String headerName) Retrieves 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.Gets full details about delivery error of a chat message.Messages can carry external body as defined by rfc2017.Gets the file transfer information (used by callbacks to recover informations
during a rcs file transfer)
Gets the forward info if available as a string.Gets 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.Returns the peer (remote) address of the message.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()
Gets the state of the message.Deprecated.01/07/2020.long
getTime()
Gets the time the message was sent.Gets destination of the message.boolean
Gets if a chat message is to be stored.Gets the object stored in this object user's dataGets 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
Gets if the message was end-to-end encrypted when transferred.boolean
isText()
Deprecated.void
Marks the message as read.int
putChar
(int character) Fulfills a chat message character by character and send the character
immediately as real-time text (RFC4103 / T.140) or as Baudot tones.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()
Sends a chat message.void
setAppdata
(String data) Linphone message has an app-specific field that can store a text.void
setContentType
(String contentType) Sets the content type of a chat message.void
setExternalBodyUrl
(String externalBodyUrl) Messages can carry external body as defined by rfc2017.void
setToBeStored
(boolean toBeStored) Sets 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) Sets a text to be sent, given as a string of UTF-8 characters.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 SIP call-id 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
Gets the content type of a chat message.
- Returns:
- The content type of the chat message
-
setContentType
Sets 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
Gets full details about delivery error of a chat message.
- Returns:
- a
ErrorInfo
describing the details.
-
getExternalBodyUrl
Messages can carry external body as defined by rfc2017.
- Returns:
- external body url or null if not present.
-
setExternalBodyUrl
Messages can carry external body as defined by rfc2017.
- Parameters:
externalBodyUrl
- ex: access-type=URL; URL="http://www.foo.com/file"
-
getFileTransferInformation
Gets the file transfer information (used by callbacks 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
Gets 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()Gets if the message was end-to-end encrypted when transferred.
- Returns:
- true if the message was end-to-end encrypted when transferred, 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.
-
getPeerAddress
Returns the peer (remote) address of the message.
- Returns:
- the
Address
of the peer address used to send/receive this
message.
-
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()Gets 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()Gets the time the message was sent.
- Returns:
- the timestamp of when the message was sent.
-
getToAddress
Gets destination of the message.
- Returns:
- the
Address
of the recipient.
-
getToBeStored
boolean getToBeStored()Gets if a chat message is to be stored.
- Returns:
- Whether or not the message is to be stored
-
setToBeStored
void setToBeStored(boolean toBeStored) Sets 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
Gets text part of this message.
- Returns:
- The text as UTF8 characters or null if no text.
-
setUtf8Text
Sets a text to be sent, given as a string of UTF-8 characters.
- 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
Adds 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 to add to the message.
-
cancelFileTransfer
void cancelFileTransfer()Cancels 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.
-
downloadContents
boolean downloadContents()Starts the download of all theContent
objects representing file
transfers included in the message (Content.isFileTransfer()
method
returns true).
- Returns:
- false if there is an error, true otherwise.
-
getCustomHeader
Retrieves 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.
-
markAsRead
void markAsRead()Marks the message as read.
Only triggers LinphoneChatRoomCbsChatRoomReadCb if it was the last unread
message. -
putChar
int putChar(int character) Fulfills a chat message character by character and send the character
immediately as real-time text (RFC4103 / T.140) or as Baudot tones.
The method used to send the character depends on if real-time text is enabled
or not. If it is, real-time text is of course used, otherwise Baudot will be
used if it is enabled in theCore
(seeCore#enableBaudot
). If
real-time text is used, theChatRoom
the message was created from must
be a real-time text capable chat room: it must be obtained by placing or
receiving a call with real-time text capabilities (seeCallParams#enableRealtimeText
), and getting theChatRoom
interface from the call withCall.getChatRoom()
. When the message is terminated (ie a new line needs to be started), use
send()
in order to trigger the sending of the new line character and
have the full message (comprising all characters sent so far) stored in local
database.- Parameters:
character
- The character to send (T.140 char for real-time text).- 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()Sends 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()
-