Liblinphone
5.4.0
|
A ChatMessage represents an instant message that can be send or received through a ChatRoom. More...
#include <chat_message.hh>
Public Types | |
enum | Direction { Direction::Incoming = 0, Direction::Outgoing = 1 } |
Direction is used to indicate if a message is outgoing or incoming. More... | |
enum | State { State::Idle = 0, State::InProgress = 1, State::Delivered = 2, State::NotDelivered = 3, State::FileTransferError = 4, State::FileTransferDone = 5, State::DeliveredToUser = 6, State::Displayed = 7, State::FileTransferInProgress = 8, State::PendingDelivery = 9, State::FileTransferCancelling = 10 } |
State is used to notify if messages have been successfully delivered or not. More... | |
Public Member Functions | |
LINPHONECXX_PUBLIC | ChatMessage (void *ptr, bool takeRef=true) |
LINPHONECXX_PUBLIC _LinphoneChatMessage * | cPtr () |
LINPHONECXX_PUBLIC void | addListener (const std::shared_ptr< ChatMessageListener > &listener) |
Add an application listener to the ChatMessage instance. More... | |
LINPHONECXX_PUBLIC void | removeListener (const std::shared_ptr< ChatMessageListener > &listener) |
Remove a previously added listener from the ChatMessage instance. More... | |
LINPHONECXX_PUBLIC std::string | getAppdata () const |
Linphone message has an app-specific field that can store a text. More... | |
LINPHONECXX_PUBLIC void | setAppdata (const std::string &data) |
Linphone message has an app-specific field that can store a text. More... | |
LINPHONECXX_PUBLIC std::string | getCallId () const |
Gets the SIP call-id accociated with the message. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< linphone::ChatRoom > | getChatRoom () const |
Returns the chatroom this message belongs to. More... | |
LINPHONECXX_PUBLIC std::string | getContentType () const |
Gets the content type of a chat message. More... | |
LINPHONECXX_PUBLIC void | setContentType (const std::string &contentType) |
Sets the content type of a chat message. More... | |
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::Content > > | getContents () const |
Returns the list of contents in the message. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Core > | getCore () const |
Returns back pointer to Core object. More... | |
LINPHONECXX_PUBLIC time_t | getEphemeralExpireTime () const |
Returns the real time at which an ephemeral message expires and will be deleted. More... | |
LINPHONECXX_PUBLIC long | getEphemeralLifetime () const |
Returns lifetime of an ephemeral message. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::ErrorInfo > | getErrorInfo () const |
Gets full details about delivery error of a chat message. More... | |
LINPHONECXX_PUBLIC std::string | getExternalBodyUrl () const |
Messages can carry external body as defined by rfc2017. More... | |
LINPHONECXX_PUBLIC void | setExternalBodyUrl (const std::string &externalBodyUrl) |
Messages can carry external body as defined by rfc2017. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Content > | getFileTransferInformation () const |
Gets the file transfer information (used by callbacks to recover informations during a rcs file transfer) More... | |
LINPHONECXX_PUBLIC std::string | getForwardInfo () const |
Gets the forward info if available as a string. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getFromAddress () const |
Gets origin of the message. More... | |
LINPHONECXX_PUBLIC bool | isEphemeral () const |
Returns wether the chat message is an ephemeral message or not. More... | |
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED bool | isFileTransfer () const |
Return whether or not a chat message is a file transfer. More... | |
LINPHONECXX_PUBLIC bool | isFileTransferInProgress () const |
Gets whether or not a file is currently being downloaded or uploaded. More... | |
LINPHONECXX_PUBLIC bool | isForward () |
Returns wether the chat message is a forward message or not. More... | |
LINPHONECXX_PUBLIC bool | isOutgoing () const |
Returns wehther the message has been sent or received. More... | |
LINPHONECXX_PUBLIC bool | isRead () const |
Returns wether the message has been read or not. More... | |
LINPHONECXX_PUBLIC bool | isReply () |
Returns wether the chat message is a reply message or not. More... | |
LINPHONECXX_PUBLIC bool | isSecured () const |
Gets if the message was end-to-end encrypted when transferred. More... | |
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED bool | isText () const |
Return whether or not a chat message is a text. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getLocalAddress () const |
Returns the local address the message was sent or received with. More... | |
LINPHONECXX_PUBLIC std::string | getMessageId () const |
Get the message identifier. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::ChatMessageReaction > | getOwnReaction () const |
Returns our own reaction for a given chat message, if any. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getPeerAddress () const |
Returns the peer (remote) address of the message. More... | |
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::ChatMessageReaction > > | getReactions () const |
Gets the list of reactions received for this chat message. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< linphone::ChatMessage > | getReplyMessage () |
Returns the ChatMessage this message is a reply to. More... | |
LINPHONECXX_PUBLIC std::string | getReplyMessageId () |
Returns the ID of the message this is a reply to. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getReplyMessageSenderAddress () |
Returns the address of the sender of the message this is a reply to. More... | |
LINPHONECXX_PUBLIC State | getState () const |
Gets the state of the message. More... | |
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED std::string | getTextContent () const |
Gets the text content if available as a string. More... | |
LINPHONECXX_PUBLIC time_t | getTime () const |
Gets the time the message was sent. More... | |
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getToAddress () const |
Gets destination of the message. More... | |
LINPHONECXX_PUBLIC bool | getToBeStored () const |
Gets if a chat message is to be stored. More... | |
LINPHONECXX_PUBLIC void | setToBeStored (bool toBeStored) |
Sets if a chat message is to be stored. More... | |
LINPHONECXX_PUBLIC std::string | getUtf8Text () const |
Gets text part of this message. More... | |
LINPHONECXX_PUBLIC int | setUtf8Text (const std::string &text) |
Sets a text to be sent, given as a string of UTF-8 characters. More... | |
LINPHONECXX_PUBLIC void | addContent (const std::shared_ptr< linphone::Content > &content) |
Adds a content to the ChatMessage. More... | |
LINPHONECXX_PUBLIC void | addCustomHeader (const std::string &headerName, const std::string &headerValue) |
Adds custom headers to the message. More... | |
LINPHONECXX_PUBLIC void | addFileContent (const std::shared_ptr< linphone::Content > &content) |
Adds a file content to the ChatMessage. More... | |
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED void | addTextContent (const std::string &text) |
Creates a Content of type PlainText with the given text as body. More... | |
LINPHONECXX_PUBLIC void | addUtf8TextContent (const std::string &text) |
Creates a Content of type text/plain with the provided string, and attach it to the message. More... | |
LINPHONECXX_PUBLIC void | cancelFileTransfer () |
Cancels an ongoing file transfer attached to this message (upload or download). | |
LINPHONECXX_PUBLIC std::shared_ptr< linphone::ChatMessageReaction > | createReaction (const std::string &utf8Reaction) |
Creates a emoji reaction for the given chat mesage. More... | |
LINPHONECXX_PUBLIC bool | downloadContent (const std::shared_ptr< linphone::Content > &content) |
Starts the download of the Content referenced in the ChatMessage from remote server. More... | |
LINPHONECXX_PUBLIC bool | downloadContents () |
Starts the download of all the Content objects representing file transfers included in the message (Content::isFileTransfer() method returns true). More... | |
LINPHONECXX_PUBLIC std::string | getCustomHeader (const std::string &headerName) const |
Retrieves a custom header value given its name. More... | |
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::ParticipantImdnState > > | getParticipantsByImdnState (State state) const |
Gets the list of participants for which the imdn state has reached the specified state and the time at which they did. More... | |
LINPHONECXX_PUBLIC bool | hasConferenceInvitationContent () const |
Returns wether the chat message has a conference invitation content or not. More... | |
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED bool | hasTextContent () const |
Returns wether the chat message has a text content or not. More... | |
LINPHONECXX_PUBLIC void | markAsRead () |
Marks the message as read. More... | |
LINPHONECXX_PUBLIC linphone::Status | putChar (uint32_t character) |
Fulfills a chat message character by character and send the character immediately as real-time text (RFC4103 / T.140) or as Baudot tones. More... | |
LINPHONECXX_PUBLIC void | removeContent (const std::shared_ptr< linphone::Content > &content) |
Removes a content from the ChatMessage. More... | |
LINPHONECXX_PUBLIC void | removeCustomHeader (const std::string &headerName) |
Removes a custom header from the message. More... | |
LINPHONECXX_PUBLIC void | send () |
Sends a chat message. | |
A ChatMessage represents an instant message that can be send or received through a ChatRoom.
To create a ChatMessage, use ChatRoom::createEmptyMessage(), then either add text using addUtf8TextContent() or a Content with file informations using addFileContent(). A valid Content for file 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 file transfer server URL with Core::setFileTransferServer(). On the receiving side, either use downloadContent() to download received files or enable auto-download in the Core using Core::setMaxSizeForAutoDownloadIncomingFiles(), -1 disabling the feature and 0 always downloading files no matter it's size. Keep in mind a ChatMessage created by a ChatRoom::Backend::Basic ChatRoom can only contain one Content, either text or file.
|
strong |
Direction is used to indicate if a message is outgoing or incoming.
Enumerator | |
---|---|
Incoming | Incoming message. |
Outgoing | Outgoing message. |
|
strong |
State is used to notify if messages have been successfully delivered or not.
LINPHONECXX_PUBLIC void linphone::ChatMessage::addContent | ( | const std::shared_ptr< linphone::Content > & | content | ) |
Adds a content to the ChatMessage.
content | the Content object to add. |
LINPHONECXX_PUBLIC void linphone::ChatMessage::addCustomHeader | ( | const std::string & | headerName, |
const std::string & | headerValue | ||
) |
Adds custom headers to the message.
headerName | name of the header |
headerValue | header value |
LINPHONECXX_PUBLIC void linphone::ChatMessage::addFileContent | ( | const std::shared_ptr< linphone::Content > & | content | ) |
Adds a file content to the ChatMessage.
content | the Content object to add. |
LINPHONECXX_PUBLIC void linphone::ChatMessage::addListener | ( | const std::shared_ptr< ChatMessageListener > & | listener | ) |
Add an application listener to the ChatMessage instance.
listener | the application listener |
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED void linphone::ChatMessage::addTextContent | ( | const std::string & | text | ) |
Creates a Content of type PlainText with the given text as body.
text | The text in System Locale to add to the message. |
LINPHONECXX_PUBLIC void linphone::ChatMessage::addUtf8TextContent | ( | const std::string & | text | ) |
Creates a Content of type text/plain with the provided string, and attach it to the message.
text | The text to add to the message. |
LINPHONECXX_PUBLIC std::shared_ptr<linphone::ChatMessageReaction> linphone::ChatMessage::createReaction | ( | const std::string & | utf8Reaction | ) |
Creates a emoji reaction for the given chat mesage.
To send it, use ChatMessageReaction::send().
utf8Reaction | the emoji character(s) as UTF-8. |
LINPHONECXX_PUBLIC bool linphone::ChatMessage::downloadContent | ( | const std::shared_ptr< linphone::Content > & | content | ) |
Starts the download of the Content referenced in the ChatMessage from remote server.
content | the Content object to download (must have the Content::isFileTransfer() method return true). |
LINPHONECXX_PUBLIC bool linphone::ChatMessage::downloadContents | ( | ) |
Starts the download of all the Content objects representing file transfers included in the message (Content::isFileTransfer() method returns true).
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getAppdata | ( | ) | const |
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.
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getCallId | ( | ) | const |
Gets the SIP call-id accociated with the message.
LINPHONECXX_PUBLIC std::shared_ptr<linphone::ChatRoom> linphone::ChatMessage::getChatRoom | ( | ) | const |
Returns the chatroom this message belongs to.
LINPHONECXX_PUBLIC std::list<std::shared_ptr<linphone::Content> > linphone::ChatMessage::getContents | ( | ) | const |
Returns the list of contents in the message.
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getContentType | ( | ) | const |
Gets the content type of a chat message.
LINPHONECXX_PUBLIC std::shared_ptr<linphone::Core> linphone::ChatMessage::getCore | ( | ) | const |
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getCustomHeader | ( | const std::string & | headerName | ) | const |
Retrieves a custom header value given its name.
headerName | header name searched |
LINPHONECXX_PUBLIC time_t linphone::ChatMessage::getEphemeralExpireTime | ( | ) | const |
Returns the real time at which an ephemeral message expires and will be deleted.
LINPHONECXX_PUBLIC long linphone::ChatMessage::getEphemeralLifetime | ( | ) | const |
Returns lifetime of an ephemeral message.
The lifetime is the duration after which the ephemeral message will disappear once viewed.
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::ErrorInfo> linphone::ChatMessage::getErrorInfo | ( | ) | const |
Gets full details about delivery error of a chat message.
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getExternalBodyUrl | ( | ) | const |
Messages can carry external body as defined by rfc2017.
LINPHONECXX_PUBLIC std::shared_ptr<linphone::Content> linphone::ChatMessage::getFileTransferInformation | ( | ) | const |
Gets the file transfer information (used by callbacks to recover informations during a rcs file transfer)
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getForwardInfo | ( | ) | const |
Gets the forward info if available as a string.
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::Address> linphone::ChatMessage::getFromAddress | ( | ) | const |
Gets origin of the message.
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::Address> linphone::ChatMessage::getLocalAddress | ( | ) | const |
Returns the local address the message was sent or received with.
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getMessageId | ( | ) | const |
Get the message identifier.
It is used to identify a message so that it can be notified as delivered and/or displayed.
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::ChatMessageReaction> linphone::ChatMessage::getOwnReaction | ( | ) | const |
Returns our own reaction for a given chat message, if any.
LINPHONECXX_PUBLIC std::list<std::shared_ptr<linphone::ParticipantImdnState> > linphone::ChatMessage::getParticipantsByImdnState | ( | State | state | ) | const |
Gets the list of participants for which the imdn state has reached the specified state and the time at which they did.
state | The LinphoneChatMessageState the imdn have reached (only use LinphoneChatMessageStateDelivered, LinphoneChatMessageStateDeliveredToUser, LinphoneChatMessageStateDisplayed and LinphoneChatMessageStateNotDelivered) |
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::Address> linphone::ChatMessage::getPeerAddress | ( | ) | const |
Returns the peer (remote) address of the message.
LINPHONECXX_PUBLIC std::list<std::shared_ptr<linphone::ChatMessageReaction> > linphone::ChatMessage::getReactions | ( | ) | const |
Gets the list of reactions received for this chat message.
Warning: list is ordered by content of reaction message, not by received timestamp!
LINPHONECXX_PUBLIC std::shared_ptr<linphone::ChatMessage> linphone::ChatMessage::getReplyMessage | ( | ) |
Returns the ChatMessage this message is a reply to.
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getReplyMessageId | ( | ) |
Returns the ID of the message this is a reply to.
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::Address> linphone::ChatMessage::getReplyMessageSenderAddress | ( | ) |
Returns the address of the sender of the message this is a reply to.
LINPHONECXX_PUBLIC State linphone::ChatMessage::getState | ( | ) | const |
Gets the state of the message.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED std::string linphone::ChatMessage::getTextContent | ( | ) | const |
Gets the text content if available as a string.
LINPHONECXX_PUBLIC time_t linphone::ChatMessage::getTime | ( | ) | const |
Gets the time the message was sent.
LINPHONECXX_PUBLIC std::shared_ptr<const linphone::Address> linphone::ChatMessage::getToAddress | ( | ) | const |
Gets destination of the message.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::getToBeStored | ( | ) | const |
Gets if a chat message is to be stored.
LINPHONECXX_PUBLIC std::string linphone::ChatMessage::getUtf8Text | ( | ) | const |
Gets text part of this message.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::hasConferenceInvitationContent | ( | ) | const |
Returns wether the chat message has a conference invitation content or not.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED bool linphone::ChatMessage::hasTextContent | ( | ) | const |
Returns wether the chat message has a text content or not.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isEphemeral | ( | ) | const |
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.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED bool linphone::ChatMessage::isFileTransfer | ( | ) | const |
Return whether or not a chat message is a file transfer.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isFileTransferInProgress | ( | ) | const |
Gets whether or not a file is currently being downloaded or uploaded.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isForward | ( | ) |
Returns wether the chat message is a forward message or not.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isOutgoing | ( | ) | const |
Returns wehther the message has been sent or received.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isRead | ( | ) | const |
Returns wether the message has been read or not.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isReply | ( | ) |
Returns wether the chat message is a reply message or not.
LINPHONECXX_PUBLIC bool linphone::ChatMessage::isSecured | ( | ) | const |
Gets if the message was end-to-end encrypted when transferred.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED bool linphone::ChatMessage::isText | ( | ) | const |
Return whether or not a chat message is a text.
LINPHONECXX_PUBLIC void linphone::ChatMessage::markAsRead | ( | ) |
Marks the message as read.
Only triggers LinphoneChatRoomCbsChatRoomReadCb if it was the last unread message.
LINPHONECXX_PUBLIC linphone::Status linphone::ChatMessage::putChar | ( | uint32_t | 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 the Core (see Core::enableBaudot()). If real-time text is used, the ChatRoom 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 (see CallParams::enableRealtimeText() ), and getting the ChatRoom interface from the call with Call::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.
character | The character to send (T.140 char for real-time text). |
LINPHONECXX_PUBLIC void linphone::ChatMessage::removeContent | ( | const std::shared_ptr< linphone::Content > & | content | ) |
Removes a content from the ChatMessage.
content | the Content object to remove. |
LINPHONECXX_PUBLIC void linphone::ChatMessage::removeCustomHeader | ( | const std::string & | headerName | ) |
Removes a custom header from the message.
headerName | name of the header to remove |
LINPHONECXX_PUBLIC void linphone::ChatMessage::removeListener | ( | const std::shared_ptr< ChatMessageListener > & | listener | ) |
Remove a previously added listener from the ChatMessage instance.
listener | the application listener |
LINPHONECXX_PUBLIC void linphone::ChatMessage::setAppdata | ( | const std::string & | data | ) |
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.
data | the data to store into the message. |
LINPHONECXX_PUBLIC void linphone::ChatMessage::setContentType | ( | const std::string & | contentType | ) |
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.
contentType | The new content type of the chat message |
LINPHONECXX_PUBLIC void linphone::ChatMessage::setExternalBodyUrl | ( | const std::string & | externalBodyUrl | ) |
Messages can carry external body as defined by rfc2017.
externalBodyUrl | ex: access-type=URL; URL="http://www.foo.com/file" |
LINPHONECXX_PUBLIC void linphone::ChatMessage::setToBeStored | ( | bool | 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.
toBeStored | Whether or not the chat message is to be stored |
LINPHONECXX_PUBLIC int linphone::ChatMessage::setUtf8Text | ( | const std::string & | text | ) |
Sets a text to be sent, given as a string of UTF-8 characters.
text | The text in UTF8 to set. |