Interface PresenceModel


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

  • Method Details

    • getActivity

      @Nullable 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 < 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

      @Nullable 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(@Nullable String contact)
      Sets the contact of a presence model.

      Parameters:
      contact - The contact string to set.
      Returns:
      0 if successful, a value < 0 in case of error.
    • isOnline

      boolean isOnline()
      Tells whether a presence model is considered online.

      It is any of theses cases:
    • 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

      @Nullable 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(@Nullable 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 < 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(@NonNull 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 < 0 in case of error.
    • addNote

      int addNote(@NonNull String noteContent, @Nullable 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 < 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(@NonNull 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 < 0 in case of error.
    • addService

      int addService(@NonNull 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 < 0 in case of error.
    • clearActivities

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

      Returns:
      0 if successful, a value < 0 in case of error.
    • clearNotes

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

      Returns:
      0 if successful, a value < 0 in case of error.
    • clearPersons

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

      Returns:
      0 if successful, a value < 0 in case of error.
    • clearServices

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

      Returns:
      0 if successful, a value < 0 in case of error.
    • getCapabilityVersion

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

      Parameters:
      capability - The Friend#Capability to test.
      Returns:
      the version of the capability of a PresenceModel or -1.0 if the
      model has not the capability.
    • getNote

      @Nullable PresenceNote getNote(@Nullable 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

      @Nullable 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

      @Nullable 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

      @Nullable 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 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 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, @Nullable String description)
      Sets the activity of a presence model (limits to only one activity).

      Parameters:
      activity - The 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 < 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

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

      Parameters:
      activity - The 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)
      The created presence model has the activity specified in the parameters.
    • newWithActivityAndNote

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

      Parameters:
      activity - The 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: 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 and the note 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