Package org.linphone.core

# Interface PresenceModel

public interface PresenceModel
Presence model type holding information about the presence of a person.

## Method Summary

Modifier and Type
Method
Description
`int`
`addActivity(PresenceActivity activity)`
Adds an activity to a presence model.
`int`
`addNote(String noteContent, String lang)`
Adds a note to a presence model.
`int`
`addPerson(PresencePerson person)`
Adds a person to a presence model.
`int`
`addService(PresenceService service)`
Adds a service to a presence model.
`int`
`clearActivities()`
Clears the activities of a presence model.
`int`
`clearNotes()`
Clears all the notes of a presence model.
`int`
`clearPersons()`
Clears the persons of a presence model.
`int`
`clearServices()`
Clears the services of a presence model.
`PresenceActivity`
`getActivity()`
Gets the first activity of a presence model (there is usually only one).
`PresenceBasicStatus`
`getBasicStatus()`
Gets the basic status of a presence model.
`int`
`getCapabilities()`
Gets the capabilities of a `PresenceModel` object.
`float`
`getCapabilityVersion(Friend.Capability capability)`
Returns the version of the capability of a `PresenceModel`.
`ConsolidatedPresence`
`getConsolidatedPresence()`
Get the consolidated presence from a presence model.
`String`
`getContact()`
Gets the contact of a presence model.
`long`
`getLatestActivityTimestamp()`
Gets the latest activity timestamp of a presence model.
`long`
`getNativePointer()`
Gets the native pointer used by this class to make native method calls.
`int`
`getNbActivities()`
Gets the number of activities included in the presence model.
`int`
`getNbPersons()`
Gets the number of persons included in the presence model.
`int`
`getNbServices()`
Gets the number of services included in the presence model.
`PresenceNote`
`getNote(String lang)`
Gets the first note of a presence model (there is usually only one).
`PresenceActivity`
`getNthActivity(int index)`
Gets the nth activity of a presence model.
`PresencePerson`
`getNthPerson(int index)`
Gets the nth person of a presence model.
`PresenceService`
`getNthService(int index)`
Gets the nth service of a presence model.
`Address`
`getPresentity()`
Gets the presentity of a presence model.
`long`
`getTimestamp()`
Gets the timestamp of a presence model.
`Object`
`getUserData()`
Gets the object stored in this object user's data
`boolean`
`hasCapability(Friend.Capability capability)`
Returns whether or not the `PresenceModel` object has a given capability.
`boolean`
`hasCapabilityWithVersion(Friend.Capability capability, float version)`
Returns whether or not the `PresenceModel` object has a given capability
with a certain version.
`boolean`
`hasCapabilityWithVersionOrMore(Friend.Capability capability, float version)`
Returns whether or not the `PresenceModel` object has a given capability
with a certain version or more.
`boolean`
`isOnline()`
Tells whether a presence model is considered online.
`PresenceModel`
`newWithActivity(PresenceActivity.Type activity, String description)`
Creates a presence model specifying an activity.
`PresenceModel`
`newWithActivityAndNote(PresenceActivity.Type activity, String description, String note, String lang)`
Creates a presence model specifying an activity and adding a note.
`PresenceModel`
`newWithConsolidatedPresence(ConsolidatedPresence presence)`
Creates a presence model with a consolidated presence.
`int`
`setActivity(PresenceActivity.Type activity, String description)`
Sets the activity of a presence model (limits to only one activity).
`int`
`setBasicStatus(PresenceBasicStatus basicStatus)`
Sets the basic status of a presence model.
`int`
`setContact(String contact)`
Sets the contact of a presence model.
`int`
`setPresentity(Address presentity)`
Sets the presentity of a presence model.
`void`
`setUserData(Object data)`
Sets the object to store in this object user's data
`String`
`toString()`

## Method Details

### getActivity

PresenceActivity getActivity()
Gets the first activity of a presence model (there is usually only one).

Returns:
  A `PresenceActivity` object if successful, null otherwise.

### getBasicStatus

PresenceBasicStatus getBasicStatus()
Gets the basic status of a presence model.

Returns:
  The `PresenceBasicStatus` of the `PresenceModel` object
  given as parameter.

### setBasicStatus

int setBasicStatus(PresenceBasicStatus basicStatus)
Sets the basic status of a presence model.

Parameters:
  `basicStatus` - The `PresenceBasicStatus` to set for the `PresenceModel`
  object.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### getCapabilities

int getCapabilities()
Gets the capabilities of a `PresenceModel` object.

Returns:
  the capabilities.

### getConsolidatedPresence

ConsolidatedPresence getConsolidatedPresence()
Get the consolidated presence from a presence model.

Returns:
  The `ConsolidatedPresence` corresponding to the presence model

### getContact

String getContact()
Gets the contact of a presence model.

Returns:
  A pointer to a dynamically allocated string containing the contact, or
  null if no contact is found.
  The returned string is to be freed by calling ms_free().

### setContact

int setContact(String contact)
Sets the contact of a presence model.

Parameters:
  `contact` - The contact string to set.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### isOnline

boolean isOnline()
Tells whether a presence model is considered online.
It is any of theses cases:
-basic status is'open' and no activities
-explicit 'online' tag in the status

### getLatestActivityTimestamp

long getLatestActivityTimestamp()
Gets the latest activity timestamp of a presence model.

Returns:
  The activity timestamp of the `PresenceModel` object or -1 if
  there is no activity (such as when status is Online).

### getNbActivities

int getNbActivities()
Gets the number of activities included in the presence model.

Returns:
  The number of activities included in the `PresenceModel` object.

### getNbPersons

int getNbPersons()
Gets the number of persons included in the presence model.

Returns:
  The number of persons included in the `PresenceModel` object.

### getNbServices

int getNbServices()
Gets the number of services included in the presence model.

Returns:
  The number of services included in the `PresenceModel` object.

### getPresentity

Address getPresentity()
Gets the presentity of a presence model.

Returns:
  A pointer to a const `Address`, or null if no contact is found.

### setPresentity

int setPresentity(Address presentity)
Sets the presentity of a presence model.

Parameters:
  `presentity` - The presentity address to set (presentity is copied).
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### getTimestamp

long getTimestamp()
Gets the timestamp of a presence model.

Returns:
  The timestamp of the `PresenceModel` object or -1 on error.

### addActivity

int addActivity(PresenceActivity activity)
Adds an activity to a presence model.

Parameters:
  `activity` - The `PresenceActivity` object to add to the model.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### addNote

int addNote(String noteContent, String lang)
Adds a note to a presence model.

Parameters:
  `noteContent` - The note to be added to the presence model.
  `lang` - The language of the note to be added. Can be null if no language is
  to be specified for the note.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.
  Only one note for each language can be set, so e.g. setting a note for the 'fr'
  language if there is only one will replace the existing one.

### addPerson

int addPerson(PresencePerson person)
Adds a person to a presence model.

Parameters:
  `person` - The `PresencePerson` object to add to the model.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### addService

int addService(PresenceService service)
Adds a service to a presence model.

Parameters:
  `service` - The `PresenceService` object to add to the model.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### clearActivities

int clearActivities()
Clears the activities of a presence model.

Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### clearNotes

int clearNotes()
Clears all the notes of a presence model.

Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### clearPersons

int clearPersons()
Clears the persons of a presence model.

Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### clearServices

int clearServices()
Clears the services of a presence model.

Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.

### getCapabilityVersion

float getCapabilityVersion(Friend.Capability capability)
Returns the version of the capability of a `PresenceModel`.

Parameters:
  `capability` - The
  invalid reference

      Friend#Capability

  to test.
Returns:
  the version of the capability of a `PresenceModel` or -1.0 if the
  model has not the capability.

### getNote

PresenceNote getNote(String lang)
Gets the first note of a presence model (there is usually only one).

Parameters:
  `lang` - The language of the note to get. Can be null to get a note that has
  no language specified or to get the first note whatever language it is written
  into.
Returns:
  A pointer to a `PresenceNote` object if successful, null
  otherwise.

### getNthActivity

PresenceActivity getNthActivity(int index)
Gets the nth activity of a presence model.

Parameters:
  `index` - The index of the activity to get (the first activity having the
  index 0).
Returns:
  A pointer to a `PresenceActivity` object if successful, null
  otherwise.

### getNthPerson

PresencePerson getNthPerson(int index)
Gets the nth person of a presence model.

Parameters:
  `index` - The index of the person to get (the first person having the index
  0).
Returns:
  A pointer to a `PresencePerson` object if successful, null
  otherwise.

### getNthService

PresenceService getNthService(int index)
Gets the nth service of a presence model.

Parameters:
  `index` - The index of the service to get (the first service having the
  index 0).
Returns:
  A pointer to a `PresenceService` object if successful, null
  otherwise.

### hasCapability

boolean hasCapability(Friend.Capability capability)
Returns whether or not the `PresenceModel` object has a given capability.

Parameters:
  `capability` - The capability to test.
Returns:
  whether or not the `PresenceModel` object has a given capability.

### hasCapabilityWithVersion

boolean hasCapabilityWithVersion(Friend.Capability capability, float version)
Returns whether or not the `PresenceModel` object has a given capability
with a certain version.

Parameters:
  `capability` - The
  invalid reference

      Friend#Capability

  to test.
  `version` - The wanted version to test.
Returns:
  whether or not the `PresenceModel` object has a given capability
  with a certain version.

### hasCapabilityWithVersionOrMore

boolean hasCapabilityWithVersionOrMore(Friend.Capability capability, float version)
Returns whether or not the `PresenceModel` object has a given capability
with a certain version or more.

Parameters:
  `capability` - The
  invalid reference

      Friend#Capability

  to test.
  `version` - The wanted version to test.
Returns:
  whether or not the `PresenceModel` object has a given capability
  with a certain version or more.

### setActivity

int setActivity(PresenceActivity.Type activity, String description)
Sets the activity of a presence model (limits to only one activity).

Parameters:
  `activity` - The
  invalid reference

      PresenceActivity#Type

  to set for the model.
  `description` - An additional description of the activity to set for the
  model. Can be null if no additional description is to be added.
Returns:
  0 if successful, a value invalid input: '<' 0 in case of error.
  warning: This function will modify the basic status of the model according to
  the activity being set. If you don't want the basic status to be modified
  automatically, you can use the combination of `setBasicStatus(org.linphone.core.PresenceBasicStatus)`, `clearActivities()`
  and `addActivity(org.linphone.core.PresenceActivity)`.

### newWithActivity

PresenceModel newWithActivity(PresenceActivity.Type activity, String description)
Creates a presence model specifying an activity.

Parameters:
  `activity` - The
  invalid reference

      PresenceActivity#Type

  to set for the created
  presence model.
  `description` - An additional description of the activity (mainly useful for
  the 'other' activity). Set it to null to not add a description.
Returns:
  The created `PresenceModel`, or null if an error occured.
  see: linphone_presence_model_new, `newWithActivityAndNote(org.linphone.core.PresenceActivity.Type, java.lang.String, java.lang.String, java.lang.String)`, `newWithConsolidatedPresence(org.linphone.core.ConsolidatedPresence)`
  The created presence model has the activity specified in the parameters.

### newWithActivityAndNote

PresenceModel newWithActivityAndNote(PresenceActivity.Type activity, String description, String note, String lang)
Creates a presence model specifying an activity and adding a note.

Parameters:
  `activity` - The
  invalid reference

      PresenceActivity#Type

  to set for the created
  presence model.
  `description` - An additional description of the activity (mainly useful for
  the 'other' activity). Set it to null to not add a description.
  `note` - An additional note giving additional information about the contact
  presence.
  `lang` - The language the note is written in. It can be set to null in order
  to not specify the language of the note.
Returns:
  The created `PresenceModel`, or null if an error occured.
  see: linphone_presence_model_new, `newWithActivity(org.linphone.core.PresenceActivity.Type, java.lang.String)`, `newWithConsolidatedPresence(org.linphone.core.ConsolidatedPresence)`
  The created presence model has the activity and the note specified in the
  parameters.

### newWithConsolidatedPresence

PresenceModel newWithConsolidatedPresence(ConsolidatedPresence presence)
Creates a presence model with a consolidated presence.

Parameters:
  `presence` - The `ConsolidatedPresence` to set for the created
  presence model.
Returns:
  The created `PresenceModel`, or null if an error occured.
  warning: This function will set the basic status of the model and it may create
  an activity depending on the `ConsolidatedPresence`
  see: linphone_presence_model_new, `newWithActivity(org.linphone.core.PresenceActivity.Type, java.lang.String)`, `newWithActivityAndNote(org.linphone.core.PresenceActivity.Type, java.lang.String, java.lang.String, java.lang.String)`
  The created presence model has the activity specified in the parameters.

### setUserData

void setUserData(Object data)
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()

Overrides:
  `toString` in class `Object`