Liblinphone: linphone::Friend Class Reference

Liblinphone 5.3.0

Public Types | Public Member Functions | Static Public Member Functions | List of all members
linphone::Friend Class Reference

This object is used to store a SIP address. More...

`#include <friend.hh>`

Inheritance diagram for linphone::Friend:

## Public Types
enum class | Capability { None = 0 , GroupChat = 1<<0 , LimeX3Dh = 1<<1 , EphemeralMessages = 1<<2 }
| Enum describing the capabilities of a Friend, populated through presence subscribe/notify process. More...

## Public Member Functions
LINPHONECXX_PUBLIC | Friend (void *ptr, bool takeRef=true)
LINPHONECXX_PUBLIC _LinphoneFriend * | cPtr ()
LINPHONECXX_PUBLIC void | addListener (const std::shared_ptr< FriendListener > &listener)
| Add an application listener to the Friend instance.
LINPHONECXX_PUBLIC void | removeListener (const std::shared_ptr< FriendListener > &listener)
| Remove a previously added listener from the Friend instance.
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getAddress () const
| Get address of this friend.
LINPHONECXX_PUBLIC linphone::Status | setAddress (const std::shared_ptr< const linphone::Address > &address)
| Set Address for this friend.
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::Address > > | getAddresses () const
| Returns a list of Address for this friend.
LINPHONECXX_PUBLIC int | getCapabilities () const
| Returns the capabilities associated to this friend.
LINPHONECXX_PUBLIC linphone::ConsolidatedPresence | getConsolidatedPresence () const
| Get the consolidated presence of a friend.
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Core > | getCore () const
| Returns the Core object managing this friend, if any.
LINPHONECXX_PUBLIC linphone::SubscribePolicy | getIncSubscribePolicy () const
| get current subscription policy for this Friend
LINPHONECXX_PUBLIC linphone::Status | setIncSubscribePolicy (linphone::SubscribePolicy policy)
| Configure incoming subscription policy for this friend.
LINPHONECXX_PUBLIC bool | isPresenceReceived () const
| Tells whether we already received presence information for a friend.
LINPHONECXX_PUBLIC std::string | getJobTitle () const
| Gets the contact's job title from it's vCard.
LINPHONECXX_PUBLIC void | setJobTitle (const std::string &jobTitle)
| Sets the contact's job title.
LINPHONECXX_PUBLIC std::string | getName () const
| Get the display name for this friend.
LINPHONECXX_PUBLIC linphone::Status | setName (const std::string &name)
| Set the display name for this friend.
LINPHONECXX_PUBLIC std::string | getNativeUri () const
| Gets the contact's native URI.
LINPHONECXX_PUBLIC void | setNativeUri (const std::string &nativeUri)
| Sets the contact's native URI.
LINPHONECXX_PUBLIC std::string | getOrganization () const
| Gets the contact's organization from it's vCard.
LINPHONECXX_PUBLIC void | setOrganization (const std::string &organization)
| Sets the contact's organization.
LINPHONECXX_PUBLIC std::list< std::string > | getPhoneNumbers () const
| Returns a list of phone numbers for this friend.
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::FriendPhoneNumber > > | getPhoneNumbersWithLabel () const
| Returns a list of FriendPhoneNumber for this friend.
LINPHONECXX_PUBLIC std::string | getPhoto () const
| Gets the contact's picture URI.
LINPHONECXX_PUBLIC void | setPhoto (const std::string &pictureUri)
| Sets the contact's picture URI.
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::PresenceModel > | getPresenceModel () const
| Get the presence model of a friend.
LINPHONECXX_PUBLIC void | setPresenceModel (const std::shared_ptr< linphone::PresenceModel > &presence)
| Set the presence model of a friend.
LINPHONECXX_PUBLIC std::string | getRefKey () const
| Get the reference key of a friend.
LINPHONECXX_PUBLIC void | setRefKey (const std::string &key)
| Set the reference key of a friend.
LINPHONECXX_PUBLIC bool | getStarred () const
| Gets if the friend is to be considered as important for the user.
LINPHONECXX_PUBLIC void | setStarred (bool isStarred)
| Sets if the friend is a user's favorite or important contact.
LINPHONECXX_PUBLIC bool | subscribesEnabled () const
| get subscription flag value
LINPHONECXX_PUBLIC linphone::Status | enableSubscribes (bool enable)
| Configure Friend to subscribe to presence information.
LINPHONECXX_PUBLIC linphone::SubscriptionState | getSubscriptionState () const
| Get subscription state of a friend.
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Vcard > | getVcard () const
| Returns the vCard object associated to this friend, if any.
LINPHONECXX_PUBLIC void | setVcard (const std::shared_ptr< linphone::Vcard > &vcard)
| Binds a vCard object to a friend.
LINPHONECXX_PUBLIC void | addAddress (const std::shared_ptr< const linphone::Address > &address)
| Adds an address in this friend.
LINPHONECXX_PUBLIC void | addPhoneNumber (const std::string &phoneNumber)
| Adds a phone number in this friend.
LINPHONECXX_PUBLIC void | addPhoneNumberWithLabel (const std::shared_ptr< linphone::FriendPhoneNumber > &phoneNumber)
| Adds a FriendPhoneNumber to this friend.
LINPHONECXX_PUBLIC bool | createVcard (const std::string &name)
| Creates a vCard object associated to this friend if there isn't one yet and if the full name is available, either by the parameter or the one in the friend's SIP URI.
LINPHONECXX_PUBLIC void | done ()
| Commits modification made to the friend configuration.
LINPHONECXX_PUBLIC void | edit ()
| Starts editing a friend configuration.
LINPHONECXX_PUBLIC float | getCapabilityVersion (Capability capability) const
| Returns the version of a friend's capbility.
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::PresenceModel > | getPresenceModelForUriOrTel (const std::string &uriOrTel) const
| Get the presence model for a specific SIP URI or phone number of a friend.
LINPHONECXX_PUBLIC bool | hasCapability (Capability capability) const
| Returns whether or not a friend has a capbility.
LINPHONECXX_PUBLIC bool | hasCapabilityWithVersion (Capability capability, float version) const
| Returns whether or not a friend has a capbility with a given version.
LINPHONECXX_PUBLIC bool | hasCapabilityWithVersionOrMore (Capability capability, float version) const
| Returns whether or not a friend has a capbility with a given version or more.
LINPHONECXX_PUBLIC bool | hasPhoneNumber (const std::string &phoneNumber) const
| Returns whether a friend contains the given phone number.
LINPHONECXX_PUBLIC bool | inList () const
| Check that the given friend is in a friend list.
LINPHONECXX_PUBLIC void | remove ()
| Removes a friend from it's friend list and from the rc if exists.
LINPHONECXX_PUBLIC void | removeAddress (const std::shared_ptr< const linphone::Address > &address)
| Removes an address in this friend.
LINPHONECXX_PUBLIC void | removePhoneNumber (const std::string &phoneNumber)
| Removes a phone number in this friend.
LINPHONECXX_PUBLIC void | removePhoneNumberWithLabel (const std::shared_ptr< const linphone::FriendPhoneNumber > &phoneNumber)
| Removes a FriendPhoneNumber from this friend.
LINPHONECXX_PUBLIC void | save (const std::shared_ptr< linphone::Core > &core)
| Saves a friend either in database if configured, otherwise in linphonerc.
LINPHONECXX_PUBLIC void | setPresenceModelForUriOrTel (const std::string &uriOrTel, const std::shared_ptr< linphone::PresenceModel > &presence)
| Set the presence model for a specific SIP URI or phone number of a friend.

## Static Public Member Functions
static LINPHONECXX_PUBLIC std::shared_ptr< linphone::Friend > | newFromVcard (const std::shared_ptr< linphone::Vcard > &vcard)
| Contructor same as linphone_friend_new + setAddress().

## Detailed Description

This object is used to store a SIP address.

Friend is mainly used to implement an adressbook feature, and are used as data for the MagicSearch object. If your proxy supports it, you can also use it to subscribe to presence information. The objects are stored in a FriendList which are in turn stored inside the Core. They can be stored inside a database if the path to it is configured, otherwise they will be lost after the Core is destroyed. Thanks to the vCard plugin, you can also store more information like phone numbers, organization, etc...

## Member Enumeration Documentation

## ◆ Capability

enum class linphone::Friend::Capability
| strong

Enum describing the capabilities of a Friend, populated through presence subscribe/notify process.

Enumerator
None | No capabilities populated.
GroupChat | This friend can be invited in a Flexisip backend ChatRoom.
LimeX3Dh | This friend can be invited in a Flexisip backend end-to-end encrypted ChatRoom.
EphemeralMessages | This friend is able to delete ephemeral messages once they have expired.

## Member Function Documentation

## ◆ addAddress()

LINPHONECXX_PUBLIC void linphone::Friend::addAddress | ( | const std::shared_ptr< const linphone::Address > & | address | ) |

Adds an address in this friend.

Parameters

  address | Address object

## ◆ addListener()

LINPHONECXX_PUBLIC void linphone::Friend::addListener | ( | const std::shared_ptr< FriendListener > & | listener | ) |

Add an application listener to the Friend instance.

Parameters

  listener | the application listener

## ◆ addPhoneNumber()

LINPHONECXX_PUBLIC void linphone::Friend::addPhoneNumber | ( | const std::string & | phoneNumber | ) |

Adds a phone number in this friend.

Parameters

  phoneNumber | number to add

## ◆ addPhoneNumberWithLabel()

LINPHONECXX_PUBLIC void linphone::Friend::addPhoneNumberWithLabel | ( | const std::shared_ptr< linphone::FriendPhoneNumber > & | phoneNumber | ) |

Adds a FriendPhoneNumber to this friend.

Parameters

  phoneNumber | the FriendPhoneNumber to add

## ◆ createVcard()

LINPHONECXX_PUBLIC bool linphone::Friend::createVcard | ( | const std::string & | name | ) |

Creates a vCard object associated to this friend if there isn't one yet and if the full name is available, either by the parameter or the one in the friend's SIP URI.

Parameters

  name | The full name of the friend or nullptr to use the one from the friend's SIP URI

Returns
  true if the vCard has been created, false if it wasn't possible (for exemple if name and the friend's SIP URI are null or if the friend's SIP URI doesn't have a display name), or if there is already one vcard

## ◆ edit()

LINPHONECXX_PUBLIC void linphone::Friend::edit | ( |  | ) |

Starts editing a friend configuration.

Because friend configuration must be consistent, applications MUST call edit() before doing any attempts to modify friend configuration (such as setAddress() or setIncSubscribePolicy()). Once the modifications are done, then the application must call done() to commit the changes.

## ◆ enableSubscribes()

LINPHONECXX_PUBLIC linphone::Status linphone::Friend::enableSubscribes | ( | bool | enable | ) |

Configure Friend to subscribe to presence information.

Parameters

  enable | if true this friend will receive subscription message

Returns
  0

## ◆ getAddress()

LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > linphone::Friend::getAddress | ( |  | ) | const

Get address of this friend.

Note
  the Address object returned is hold by the Friend, however calling several time this function may return different objects.

Returns
  the Address.

## ◆ getAddresses()

LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::Address > > linphone::Friend::getAddresses | ( |  | ) | const

Returns a list of Address for this friend.

Returns
  A list of Address.

## ◆ getCapabilities()

LINPHONECXX_PUBLIC int linphone::Friend::getCapabilities | ( |  | ) | const

Returns the capabilities associated to this friend.

Returns
  an int representing the capabilities of the friend

## ◆ getCapabilityVersion()

LINPHONECXX_PUBLIC float linphone::Friend::getCapabilityVersion | ( | Capability | capability | ) | const

Returns the version of a friend's capbility.

Parameters

  capability | Capability object

Returns
  the version of a friend's capbility.

## ◆ getConsolidatedPresence()

LINPHONECXX_PUBLIC linphone::ConsolidatedPresence linphone::Friend::getConsolidatedPresence | ( |  | ) | const

Get the consolidated presence of a friend.

It will return the "most open" presence found if more than one presence model are found.

Returns
  The ConsolidatedPresence of the friend

## ◆ getCore()

LINPHONECXX_PUBLIC std::shared_ptr< linphone::Core > linphone::Friend::getCore | ( |  | ) | const

Returns the Core object managing this friend, if any.

Returns
  the Core object associated.

## ◆ getIncSubscribePolicy()

LINPHONECXX_PUBLIC linphone::SubscribePolicy linphone::Friend::getIncSubscribePolicy | ( |  | ) | const

get current subscription policy for this Friend

Returns
  the SubscribePolicy enum

## ◆ getJobTitle()

LINPHONECXX_PUBLIC std::string linphone::Friend::getJobTitle | ( |  | ) | const

Gets the contact's job title from it's vCard.

It's a shortcut to getVcard() and Vcard::getJobTitle().

Returns
  the job_title set if any & vCard is available, nullptr otherwise.

## ◆ getName()

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

Get the display name for this friend.

Returns
  The display name of this friend.

## ◆ getNativeUri()

LINPHONECXX_PUBLIC std::string linphone::Friend::getNativeUri | ( |  | ) | const

Gets the contact's native URI.

Returns
  the native URI set if any, nullptr otherwise.

## ◆ getOrganization()

LINPHONECXX_PUBLIC std::string linphone::Friend::getOrganization | ( |  | ) | const

Gets the contact's organization from it's vCard.

It's a shortcut to getVcard() and Vcard::getOrganization().

Returns
  the organization set if any & vCard is available, nullptr otherwise.

## ◆ getPhoneNumbers()

LINPHONECXX_PUBLIC std::list< std::string > linphone::Friend::getPhoneNumbers | ( |  | ) | const

Returns a list of phone numbers for this friend.

Returns
  A list of phone numbers as string.

## ◆ getPhoneNumbersWithLabel()

LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::FriendPhoneNumber > > linphone::Friend::getPhoneNumbersWithLabel | ( |  | ) | const

Returns a list of FriendPhoneNumber for this friend.

Returns
  A list of phone numbers as string.

## ◆ getPhoto()

LINPHONECXX_PUBLIC std::string linphone::Friend::getPhoto | ( |  | ) | const

Gets the contact's picture URI.

Returns
  the picture URI set if any, nullptr otherwise.

## ◆ getPresenceModel()

LINPHONECXX_PUBLIC std::shared_ptr< const linphone::PresenceModel > linphone::Friend::getPresenceModel | ( |  | ) | const

Get the presence model of a friend.

If a friend has more than one SIP address and phone number, this method will return the most recent presence model using PresenceModel::getTimestamp().

Returns
  A PresenceModel object, or nullptr if the friend do not have presence information (in which case he is considered offline).

## ◆ getPresenceModelForUriOrTel()

LINPHONECXX_PUBLIC std::shared_ptr< const linphone::PresenceModel > linphone::Friend::getPresenceModelForUriOrTel | ( | const std::string & | uriOrTel | ) | const

Get the presence model for a specific SIP URI or phone number of a friend.

Parameters

  uriOrTel | The SIP URI or phone number for which to get the presence model

Returns
  A PresenceModel object, or nullptr if the friend do not have presence information for this SIP URI or phone number.

## ◆ getRefKey()

LINPHONECXX_PUBLIC std::string linphone::Friend::getRefKey | ( |  | ) | const

Get the reference key of a friend.

Returns
  The reference key of the friend.

## ◆ getStarred()

LINPHONECXX_PUBLIC bool linphone::Friend::getStarred | ( |  | ) | const

Gets if the friend is to be considered as important for the user.

Returns
  true if the contact is a user's favorite, false otherwise.

## ◆ getSubscriptionState()

LINPHONECXX_PUBLIC linphone::SubscriptionState linphone::Friend::getSubscriptionState | ( |  | ) | const

Get subscription state of a friend.

Returns
  the SubscriptionState enum

## ◆ getVcard()

LINPHONECXX_PUBLIC std::shared_ptr< linphone::Vcard > linphone::Friend::getVcard | ( |  | ) | const

Returns the vCard object associated to this friend, if any.

Returns
  the Vcard or nullptr.

## ◆ hasCapability()

LINPHONECXX_PUBLIC bool linphone::Friend::hasCapability | ( | Capability | capability | ) | const

Returns whether or not a friend has a capbility.

Parameters

  capability | Capability object

Returns
  whether or not a friend has a capbility

## ◆ hasCapabilityWithVersion()

LINPHONECXX_PUBLIC bool linphone::Friend::hasCapabilityWithVersion | ( | Capability | capability,
|  | float | version ) const

Returns whether or not a friend has a capbility with a given version.

Parameters

  capability | Capability object
  version | the version to test

Returns
  whether or not a friend has a capbility with a given version or -1.0 if friend has not capability.

## ◆ hasCapabilityWithVersionOrMore()

LINPHONECXX_PUBLIC bool linphone::Friend::hasCapabilityWithVersionOrMore | ( | Capability | capability,
|  | float | version ) const

Returns whether or not a friend has a capbility with a given version or more.

Parameters

  capability | Capability object
  version | the version to test

Returns
  whether or not a friend has a capbility with a given version or more.

## ◆ hasPhoneNumber()

LINPHONECXX_PUBLIC bool linphone::Friend::hasPhoneNumber | ( | const std::string & | phoneNumber | ) | const

Returns whether a friend contains the given phone number.

Parameters

  phoneNumber | the phone number to search for

Returns
  true if found, false otherwise

## ◆ inList()

LINPHONECXX_PUBLIC bool linphone::Friend::inList | ( |  | ) | const

Check that the given friend is in a friend list.

Returns
  true if the friend is in a friend list, false otherwise.

## ◆ isPresenceReceived()

LINPHONECXX_PUBLIC bool linphone::Friend::isPresenceReceived | ( |  | ) | const

Tells whether we already received presence information for a friend.

Returns
  true if presence information has been received for the friend, false otherwise.

## ◆ newFromVcard()

LINPHONECXX_PUBLIC std::shared_ptr< linphone::Friend > linphone::Friend::newFromVcard | ( | const std::shared_ptr< linphone::Vcard > & | vcard | ) |
| static

Contructor same as linphone_friend_new + setAddress().

Parameters

  vcard | a Vcard object

Returns
  a new Friend which has its vCard attribute initialized from the given vCard. This can be get by getVcard().

## ◆ removeAddress()

LINPHONECXX_PUBLIC void linphone::Friend::removeAddress | ( | const std::shared_ptr< const linphone::Address > & | address | ) |

Removes an address in this friend.

Parameters

  address | Address object

## ◆ removeListener()

LINPHONECXX_PUBLIC void linphone::Friend::removeListener | ( | const std::shared_ptr< FriendListener > & | listener | ) |

Remove a previously added listener from the Friend instance.

Parameters

  listener | the application listener

## ◆ removePhoneNumber()

LINPHONECXX_PUBLIC void linphone::Friend::removePhoneNumber | ( | const std::string & | phoneNumber | ) |

Removes a phone number in this friend.

Parameters

  phoneNumber | number to remove

## ◆ removePhoneNumberWithLabel()

LINPHONECXX_PUBLIC void linphone::Friend::removePhoneNumberWithLabel | ( | const std::shared_ptr< const linphone::FriendPhoneNumber > & | phoneNumber | ) |

Removes a FriendPhoneNumber from this friend.

Parameters

  phoneNumber | the FriendPhoneNumber to remove

## ◆ save()

LINPHONECXX_PUBLIC void linphone::Friend::save | ( | const std::shared_ptr< linphone::Core > & | core | ) |

Saves a friend either in database if configured, otherwise in linphonerc.

Parameters

  core | the linphone core

## ◆ setAddress()

LINPHONECXX_PUBLIC linphone::Status linphone::Friend::setAddress | ( | const std::shared_ptr< const linphone::Address > & | address | ) |

Set Address for this friend.

Parameters

  address | the Address to set return 0 if successful, -1 otherwise

## ◆ setIncSubscribePolicy()

LINPHONECXX_PUBLIC linphone::Status linphone::Friend::setIncSubscribePolicy | ( | linphone::SubscribePolicy | policy | ) |

Configure incoming subscription policy for this friend.

Parameters

  policy | SubscribePolicy policy to apply.

Returns
  0

## ◆ setJobTitle()

LINPHONECXX_PUBLIC void linphone::Friend::setJobTitle | ( | const std::string & | jobTitle | ) |

Sets the contact's job title.

It's a shortcut to getVcard() and Vcard::setJobTitle().

Parameters

  jobTitle | the job title to store in Friend's vCard.

## ◆ setName()

LINPHONECXX_PUBLIC linphone::Status linphone::Friend::setName | ( | const std::string & | name | ) |

Set the display name for this friend.

Parameters

  name | the display name to set

Returns
  0 if successful, -1 otherwise

## ◆ setNativeUri()

LINPHONECXX_PUBLIC void linphone::Friend::setNativeUri | ( | const std::string & | nativeUri | ) |

Sets the contact's native URI.

Parameters

  nativeUri | the URI that matches the contact on the native system.

## ◆ setOrganization()

LINPHONECXX_PUBLIC void linphone::Friend::setOrganization | ( | const std::string & | organization | ) |

Sets the contact's organization.

It's a shortcut to getVcard() and Vcard::setOrganization().

Parameters

  organization | the organization to store in Friend's vCard.

## ◆ setPhoto()

LINPHONECXX_PUBLIC void linphone::Friend::setPhoto | ( | const std::string & | pictureUri | ) |

Sets the contact's picture URI.

Parameters

  pictureUri | the picture URI to set.

## ◆ setPresenceModel()

LINPHONECXX_PUBLIC void linphone::Friend::setPresenceModel | ( | const std::shared_ptr< linphone::PresenceModel > & | presence | ) |

Set the presence model of a friend.

Parameters

  presence | The PresenceModel object to set for the friend

## ◆ setPresenceModelForUriOrTel()

LINPHONECXX_PUBLIC void linphone::Friend::setPresenceModelForUriOrTel | ( | const std::string & | uriOrTel,
|  | const std::shared_ptr< linphone::PresenceModel > & | presence )

Set the presence model for a specific SIP URI or phone number of a friend.

Parameters

  uriOrTel | The SIP URI or phone number for which to set the presence model
  presence | The PresenceModel object to set

## ◆ setRefKey()

LINPHONECXX_PUBLIC void linphone::Friend::setRefKey | ( | const std::string & | key | ) |

Set the reference key of a friend.

Parameters

  key | The reference key to use for the friend.

## ◆ setStarred()

LINPHONECXX_PUBLIC void linphone::Friend::setStarred | ( | bool | isStarred | ) |

Sets if the friend is a user's favorite or important contact.

Parameters

  isStarred | true if the friend is to be considered as important, false otherwise.

## ◆ setVcard()

LINPHONECXX_PUBLIC void linphone::Friend::setVcard | ( | const std::shared_ptr< linphone::Vcard > & | vcard | ) |

Binds a vCard object to a friend.

Parameters

  vcard | The Vcard object to bind

## ◆ subscribesEnabled()

LINPHONECXX_PUBLIC bool linphone::Friend::subscribesEnabled | ( |  | ) | const

get subscription flag value

Returns
  returns true is subscription is activated for this friend

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

- friend.hh