Liblinphone: linphone::Content Class Reference

Liblinphone 5.3.0

Public Member Functions | List of all members
linphone::Content Class Reference

This object holds data that can be embedded in a signaling message. More...

`#include <content.hh>`

Inheritance diagram for linphone::Content:

## Public Member Functions
LINPHONECXX_PUBLIC | Content (void *ptr, bool takeRef=true)
LINPHONECXX_PUBLIC _LinphoneContent * | cPtr ()
LINPHONECXX_PUBLIC const uint8_t * | getBuffer () const
| Get the content data buffer, usually a string.
LINPHONECXX_PUBLIC std::string | getDisposition () const
| Get the disposition of the Content, for example "recipient-list".
LINPHONECXX_PUBLIC void | setDisposition (const std::string &disposition)
| Set the disposition of the Content, for example "recipient-list".
LINPHONECXX_PUBLIC std::string | getEncoding () const
| Get the encoding of the data buffer, for example "gzip".
LINPHONECXX_PUBLIC void | setEncoding (const std::string &encoding)
| Set the encoding of the data buffer, for example "gzip".
LINPHONECXX_PUBLIC int | getFileDuration ()
| Gets the file duration in seconds, if information is available.
LINPHONECXX_PUBLIC std::string | getFilePath () const
| Get the file transfer filepath set for this content (replace linphone_chat_message_get_file_transfer_filepath).
LINPHONECXX_PUBLIC void | setFilePath (const std::string &filePath)
| Set the file transfer filepath for this content (replace linphone_chat_message_set_file_transfer_filepath).
LINPHONECXX_PUBLIC size_t | getFileSize () const
| Get the file size if content is either a FileContent or a FileTransferContent.
LINPHONECXX_PUBLIC bool | isFile () const
| Tells whether or not this content contains a file.
LINPHONECXX_PUBLIC bool | isFileEncrypted () const
| Tells whether or not this content contains an encrypted file.
LINPHONECXX_PUBLIC bool | isFileTransfer () const
| Tells whether or not this content is a file transfer.
LINPHONECXX_PUBLIC bool | isIcalendar () const
| Tells whether or not this content contains an icalendar by checking it's content type.
LINPHONECXX_PUBLIC bool | isMultipart () const
| Tell whether a content is a multipart content.
LINPHONECXX_PUBLIC bool | isText () const
| Tells whether or not this content contains text.
LINPHONECXX_PUBLIC bool | isVoiceRecording () const
| Tells whether or not this content contains a voice recording by checking it's content type.
LINPHONECXX_PUBLIC std::string | getKey () const
| Get the key associated with a RCS file transfer message if encrypted.
LINPHONECXX_PUBLIC size_t | getKeySize () const
| Get the size of key associated with a RCS file transfer message if encrypted.
LINPHONECXX_PUBLIC std::string | getName () const
| Get the name associated with a RCS file transfer message.
LINPHONECXX_PUBLIC void | setName (const std::string &name)
| Set the name associated with a RCS file transfer message.
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::Content > > | getParts () const
| Get all the parts from a multipart content.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED std::string | getPlainFilePath () const
| Generates a temporary plain copy of the file and returns its paths The caller is responsible to then delete this temporary copy and the returned string.
LINPHONECXX_PUBLIC size_t | getSize () const
| Get the content data buffer size, excluding null character despite null character is always set for convenience.
LINPHONECXX_PUBLIC void | setSize (size_t size)
| Set the content data size, excluding null character despite null character is always set for convenience.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED std::string | getStringBuffer () const
| Get the string content data buffer.
LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED void | setStringBuffer (const std::string &buffer)
| Set the string content data buffer.
LINPHONECXX_PUBLIC std::string | getSubtype () const
| Get the mime subtype of the content data.
LINPHONECXX_PUBLIC void | setSubtype (const std::string &subtype)
| Set the mime subtype of the content data.
LINPHONECXX_PUBLIC std::string | getType () const
| Get the mime type of the content data.
LINPHONECXX_PUBLIC void | setType (const std::string &type)
| Set the mime type of the content data.
LINPHONECXX_PUBLIC std::string | getUtf8Text () const
| Get the string content data buffer.
LINPHONECXX_PUBLIC void | setUtf8Text (const std::string &buffer)
| Get the string content data buffer.
LINPHONECXX_PUBLIC void | addContentTypeParameter (const std::string &name, const std::string &value)
| Adds a parameter to the ContentType header.
LINPHONECXX_PUBLIC void | addCustomHeader (const std::string &headerName, const std::string &headerValue)
| Adds a custom header in a content.
LINPHONECXX_PUBLIC std::string | exportPlainFile () const
| Generates a temporary plain copy of the file and returns its paths The caller is responsible to then delete this temporary copy and the returned string.
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Content > | findPartByHeader (const std::string &headerName, const std::string &headerValue) const
| Find a part from a multipart content looking for a part header with a specified value.
LINPHONECXX_PUBLIC std::string | getCustomHeader (const std::string &headerName) const
| Get a custom header value of a content.
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Content > | getPart (int index) const
| Get a part from a multipart content according to its index.
LINPHONECXX_PUBLIC void | setBuffer (const uint8_t *buffer, size_t size)
| Set the content data buffer, usually a string.
LINPHONECXX_PUBLIC void | setKey (const std::string &key, const size_t keyLength)
| Set the key associated with a RCS file transfer message if encrypted.

## Detailed Description

This object holds data that can be embedded in a signaling message.

Use Core::createContent() to create it, and then you should set at least it's type and subtype and fill the buffer with your data. A Content can be multipart (contain other contents), have file information (name, path, size), be encrypted, have custom headers, etc... It is mainly used to send information through a ChatMessage.

## Member Function Documentation

## ◆ addContentTypeParameter()

LINPHONECXX_PUBLIC void linphone::Content::addContentTypeParameter | ( | const std::string & | name,
|  | const std::string & | value )

Adds a parameter to the ContentType header.

Parameters

  name | the name of the parameter to add.
  value | the value of the parameter to add.

## ◆ addCustomHeader()

LINPHONECXX_PUBLIC void linphone::Content::addCustomHeader | ( | const std::string & | headerName,
|  | const std::string & | headerValue )

Adds a custom header in a content.

Parameters

  headerName | The name of the header to add.
  headerValue | The value of the header to add.

## ◆ exportPlainFile()

LINPHONECXX_PUBLIC std::string linphone::Content::exportPlainFile | ( |  | ) | const

Generates a temporary plain copy of the file and returns its paths The caller is responsible to then delete this temporary copy and the returned string.

Returns
  The file path set for this content if it has been set, nullptr otherwise.

## ◆ findPartByHeader()

LINPHONECXX_PUBLIC std::shared_ptr< linphone::Content > linphone::Content::findPartByHeader | ( | const std::string & | headerName,
|  | const std::string & | headerValue ) const

Find a part from a multipart content looking for a part header with a specified value.

Parameters

  headerName | The name of the header to look for.
  headerValue | The value of the header to look for.

Returns
  A Content object object the part if found, nullptr otherwise.

## ◆ getBuffer()

LINPHONECXX_PUBLIC const uint8_t * linphone::Content::getBuffer | ( |  | ) | const

Get the content data buffer, usually a string.

Returns
  The content data buffer.

## ◆ getCustomHeader()

LINPHONECXX_PUBLIC std::string linphone::Content::getCustomHeader | ( | const std::string & | headerName | ) | const

Get a custom header value of a content.

Parameters

  headerName | The name of the header to get the value from.

Returns
  The value of the header if found, nullptr otherwise.

## ◆ getDisposition()

LINPHONECXX_PUBLIC std::string linphone::Content::getDisposition | ( |  | ) | const

Get the disposition of the Content, for example "recipient-list".

Returns
  The disposition of the Content.

## ◆ getEncoding()

LINPHONECXX_PUBLIC std::string linphone::Content::getEncoding | ( |  | ) | const

Get the encoding of the data buffer, for example "gzip".

Returns
  The encoding of the data buffer.

## ◆ getFileDuration()

LINPHONECXX_PUBLIC int linphone::Content::getFileDuration | ( |  | ) |

Gets the file duration in seconds, if information is available.

Returns
  The duration of the file in seconds or -1 if information isn't available.

## ◆ getFilePath()

LINPHONECXX_PUBLIC std::string linphone::Content::getFilePath | ( |  | ) | const

Get the file transfer filepath set for this content (replace linphone_chat_message_get_file_transfer_filepath).

Returns
  The file path set for this content if it has been set, nullptr otherwise.

## ◆ getFileSize()

LINPHONECXX_PUBLIC size_t linphone::Content::getFileSize | ( |  | ) | const

Get the file size if content is either a FileContent or a FileTransferContent.

Returns
  The represented file size.

## ◆ getKey()

LINPHONECXX_PUBLIC std::string linphone::Content::getKey | ( |  | ) | const

Get the key associated with a RCS file transfer message if encrypted.

Returns
  The key to encrypt/decrypt the file associated to this content.

## ◆ getKeySize()

LINPHONECXX_PUBLIC size_t linphone::Content::getKeySize | ( |  | ) | const

Get the size of key associated with a RCS file transfer message if encrypted.

Returns
  The key size in bytes

## ◆ getName()

LINPHONECXX_PUBLIC std::string linphone::Content::getName | ( |  | ) | const

Get the name associated with a RCS file transfer message.

It is used to store the original filename of the file to be downloaded from server.

Returns
  The name of the content.

## ◆ getPart()

LINPHONECXX_PUBLIC std::shared_ptr< linphone::Content > linphone::Content::getPart | ( | int | index | ) | const

Get a part from a multipart content according to its index.

Parameters

  index | The index of the part to get.

Returns
  A Content object holding the part if found, nullptr otherwise.

## ◆ getParts()

LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::Content > > linphone::Content::getParts | ( |  | ) | const

Get all the parts from a multipart content.

Returns
  A object holding the part if found, nullptr otherwise.

## ◆ getPlainFilePath()

LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED std::string linphone::Content::getPlainFilePath | ( |  | ) | const

Generates a temporary plain copy of the file and returns its paths The caller is responsible to then delete this temporary copy and the returned string.

Returns
  The file path set for this content if it has been set, nullptr otherwise.

Deprecated
  2022-01-07. Use exportPlainFile() instead.

## ◆ getSize()

LINPHONECXX_PUBLIC size_t linphone::Content::getSize | ( |  | ) | const

Get the content data buffer size, excluding null character despite null character is always set for convenience.

Returns
  The content data buffer size.

## ◆ getStringBuffer()

LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED std::string linphone::Content::getStringBuffer | ( |  | ) | const

Get the string content data buffer.

Returns
  The string content data buffer.

Deprecated
  2020-07-01. Use getUtf8Text() instead.

## ◆ getSubtype()

LINPHONECXX_PUBLIC std::string linphone::Content::getSubtype | ( |  | ) | const

Get the mime subtype of the content data.

Returns
  The mime subtype of the content data, for example "html".

## ◆ getType()

LINPHONECXX_PUBLIC std::string linphone::Content::getType | ( |  | ) | const

Get the mime type of the content data.

Returns
  The mime type of the content data, for example "application".

## ◆ getUtf8Text()

LINPHONECXX_PUBLIC std::string linphone::Content::getUtf8Text | ( |  | ) | const

Get the string content data buffer.

Introduced in 01/07/2020

Returns
  The string content data buffer in UTF8.

## ◆ isFile()

LINPHONECXX_PUBLIC bool linphone::Content::isFile | ( |  | ) | const

Tells whether or not this content contains a file.

Returns
  true if this content contains a file, false otherwise.

## ◆ isFileEncrypted()

LINPHONECXX_PUBLIC bool linphone::Content::isFileEncrypted | ( |  | ) | const

Tells whether or not this content contains an encrypted file.

Returns
  True is this content contains a file and this file is encrypted, false otherwise.

## ◆ isFileTransfer()

LINPHONECXX_PUBLIC bool linphone::Content::isFileTransfer | ( |  | ) | const

Tells whether or not this content is a file transfer.

Returns
  true if this content is a file transfer, false otherwise.

## ◆ isIcalendar()

LINPHONECXX_PUBLIC bool linphone::Content::isIcalendar | ( |  | ) | const

Tells whether or not this content contains an icalendar by checking it's content type.

Returns
  true if this content type is 'text/calendar;conference-event=yes', false otherwise.

## ◆ isMultipart()

LINPHONECXX_PUBLIC bool linphone::Content::isMultipart | ( |  | ) | const

Tell whether a content is a multipart content.

Returns
  A boolean value telling whether the content is multipart or not.

## ◆ isText()

LINPHONECXX_PUBLIC bool linphone::Content::isText | ( |  | ) | const

Tells whether or not this content contains text.

Returns
  true if this content contains plain text, false otherwise.

## ◆ isVoiceRecording()

LINPHONECXX_PUBLIC bool linphone::Content::isVoiceRecording | ( |  | ) | const

Tells whether or not this content contains a voice recording by checking it's content type.

Returns
  true if this content type is 'audio/wav;voice-recording=yes', false otherwise.

## ◆ setBuffer()

LINPHONECXX_PUBLIC void linphone::Content::setBuffer | ( | const uint8_t * | buffer,
|  | size_t | size )

Set the content data buffer, usually a string.

Parameters

  buffer | The content data buffer.
  size | The size of the content data buffer.

## ◆ setDisposition()

LINPHONECXX_PUBLIC void linphone::Content::setDisposition | ( | const std::string & | disposition | ) |

Set the disposition of the Content, for example "recipient-list".

Parameters

  disposition | The disposition of the Content.

## ◆ setEncoding()

LINPHONECXX_PUBLIC void linphone::Content::setEncoding | ( | const std::string & | encoding | ) |

Set the encoding of the data buffer, for example "gzip".

Parameters

  encoding | The encoding of the data buffer.

## ◆ setFilePath()

LINPHONECXX_PUBLIC void linphone::Content::setFilePath | ( | const std::string & | filePath | ) |

Set the file transfer filepath for this content (replace linphone_chat_message_set_file_transfer_filepath).

Parameters

  filePath | the file transfer filepath.

## ◆ setKey()

LINPHONECXX_PUBLIC void linphone::Content::setKey | ( | const std::string & | key,
|  | const size_t | keyLength )

Set the key associated with a RCS file transfer message if encrypted.

Parameters

  key | The key to be used to encrypt/decrypt file associated to this content.
  keyLength | The lengh of the key.

## ◆ setName()

LINPHONECXX_PUBLIC void linphone::Content::setName | ( | const std::string & | name | ) |

Set the name associated with a RCS file transfer message.

It is used to store the original filename of the file to be downloaded from server.

Parameters

  name | The name of the content.

## ◆ setSize()

LINPHONECXX_PUBLIC void linphone::Content::setSize | ( | size_t | size | ) |

Set the content data size, excluding null character despite null character is always set for convenience.

Parameters

  size | The content data buffer size.

## ◆ setStringBuffer()

LINPHONECXX_PUBLIC LINPHONECXX_DEPRECATED void linphone::Content::setStringBuffer | ( | const std::string & | buffer | ) |

Set the string content data buffer.

Parameters

  buffer | The string content data buffer in UTF8.

Deprecated
  2020-07-01. Use setUtf8Text() instead.

## ◆ setSubtype()

LINPHONECXX_PUBLIC void linphone::Content::setSubtype | ( | const std::string & | subtype | ) |

Set the mime subtype of the content data.

Parameters

  subtype | The mime subtype of the content data, for example "html".

## ◆ setType()

LINPHONECXX_PUBLIC void linphone::Content::setType | ( | const std::string & | type | ) |

Set the mime type of the content data.

Parameters

  type | The mime type of the content data, for example "application".

## ◆ setUtf8Text()

LINPHONECXX_PUBLIC void linphone::Content::setUtf8Text | ( | const std::string & | buffer | ) |

Get the string content data buffer.

Introduced in 01/07/2020

Parameters

  buffer | The string content data buffer in UTF8.

The documentation for this class was generated from the following file:

- content.hh