Liblinphone: linphone::Friend Class Reference

Liblinphone 5.0.0

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 Member Functions
| Friend (void *ptr, bool takeRef=true)
LINPHONECXX_PUBLIC _LinphoneFriend * | cPtr ()
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::Address > | getAddress () const
| Get address of this friend. More...
LINPHONECXX_PUBLIC linphone::Status | setAddress (const std::shared_ptr< const linphone::Address > &address)
| Set Address for this friend. More...
LINPHONECXX_PUBLIC std::list< std::shared_ptr< linphone::Address > > | getAddresses () const
| Returns a list of Address for this friend. More...
LINPHONECXX_PUBLIC int | getCapabilities () const
| Returns the capabilities associated to this friend. More...
LINPHONECXX_PUBLIC linphone::ConsolidatedPresence | getConsolidatedPresence () const
| Get the consolidated presence of a friend. More...
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Core > | getCore () const
| Returns the Core object managing this friend, if any. More...
LINPHONECXX_PUBLIC linphone::SubscribePolicy | getIncSubscribePolicy () const
| get current subscription policy for this Friend More...
LINPHONECXX_PUBLIC linphone::Status | setIncSubscribePolicy (linphone::SubscribePolicy policy)
| Configure incoming subscription policy for this friend. More...
LINPHONECXX_PUBLIC bool | isPresenceReceived () const
| Tells whether we already received presence information for a friend. More...
LINPHONECXX_PUBLIC std::string | getName () const
| Get the display name for this friend. More...
LINPHONECXX_PUBLIC linphone::Status | setName (const std::string &name)
| Set the display name for this friend. More...
LINPHONECXX_PUBLIC std::list< std::string > | getPhoneNumbers () const
| Returns a list of phone numbers for this friend. More...
LINPHONECXX_PUBLIC std::shared_ptr< const linphone::PresenceModel > | getPresenceModel () const
| Get the presence model of a friend. More...
LINPHONECXX_PUBLIC void | setPresenceModel (const std::shared_ptr< linphone::PresenceModel > &presence)
| Set the presence model of a friend. More...
LINPHONECXX_PUBLIC std::string | getRefKey () const
| Get the reference key of a friend. More...
LINPHONECXX_PUBLIC void | setRefKey (const std::string &key)
| Set the reference key of a friend. More...
LINPHONECXX_PUBLIC bool | subscribesEnabled () const
| get subscription flag value More...
LINPHONECXX_PUBLIC linphone::Status | enableSubscribes (bool enable)
| Configure Friend to subscribe to presence information. More...
LINPHONECXX_PUBLIC linphone::SubscriptionState | getSubscriptionState () const
| Get subscription state of a friend. More...
LINPHONECXX_PUBLIC std::shared_ptr< linphone::Vcard > | getVcard () const
| Returns the vCard object associated to this friend, if any. More...
LINPHONECXX_PUBLIC void | setVcard (const std::shared_ptr< linphone::Vcard > &vcard)
| Binds a vCard object to a friend. More...
LINPHONECXX_PUBLIC void | addAddress (const std::shared_ptr< const linphone::Address > &address)
| Adds an address in this friend. More...
LINPHONECXX_PUBLIC void | addPhoneNumber (const std::string &phoneNumber)
| Adds a phone number in this friend. More...
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. More...
LINPHONECXX_PUBLIC void | done ()
| Commits modification made to the friend configuration.
LINPHONECXX_PUBLIC void | edit ()
| Starts editing a friend configuration. More...
LINPHONECXX_PUBLIC float | getCapabilityVersion (linphone::FriendCapability capability) const
| Returns the version of a friend's capbility. More...
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. More...
LINPHONECXX_PUBLIC bool | hasCapability (linphone::FriendCapability capability) const
| Returns whether or not a friend has a capbility. More...
LINPHONECXX_PUBLIC bool | hasCapabilityWithVersion (linphone::FriendCapability capability, float version) const
| Returns whether or not a friend has a capbility with a given version. More...
LINPHONECXX_PUBLIC bool | hasCapabilityWithVersionOrMore (linphone::FriendCapability capability, float version) const
| Returns whether or not a friend has a capbility with a given version or more. More...
LINPHONECXX_PUBLIC bool | hasPhoneNumber (const std::string &phoneNumber) const
| Returns whether a friend contains the given phone number. More...
LINPHONECXX_PUBLIC bool | inList () const
| Check that the given friend is in a friend list. More...
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. More...
LINPHONECXX_PUBLIC void | removePhoneNumber (const std::string &phoneNumber)
| Removes a phone number in this friend. More...
LINPHONECXX_PUBLIC void | save (const std::shared_ptr< linphone::Core > &core)
| Saves a friend either in database if configured, otherwise in linphonerc. More...
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. More...

## 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() More...

## 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 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

## ◆ addPhoneNumber()

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

Adds a phone number in this friend.

Parameters

  phoneNumber | number 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 LinphoneFriend, 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 | ( | linphone::FriendCapability | capability | ) | const

Returns the version of a friend's capbility.

Parameters

  capability | FriendCapability 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.

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

## ◆ getName()

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

Get the display name for this friend.

Returns
  The display name of this friend.

## ◆ 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.

## ◆ getPresenceModel()

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

Get the presence model of a friend.

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.

## ◆ 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 | ( | linphone::FriendCapability | capability | ) | const

Returns whether or not a friend has a capbility.

Parameters

  capability | FriendCapability object

Returns
  whether or not a friend has a capbility

## ◆ hasCapabilityWithVersion()

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

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

Parameters

  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 | ( | linphone::FriendCapability | capability,
|  | float | version
| ) |  | const

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

Parameters

  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()

static 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

## ◆ removePhoneNumber()

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

Removes a phone number in this friend.

Parameters

  phoneNumber | number 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 successfull, -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

## ◆ 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

## ◆ 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

  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.

## ◆ 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