Complete presence API to have access to the notes of presence services and persons.

This commit is contained in:
Ghislain MARY 2013-09-18 14:21:44 +02:00
parent 2da7c76b36
commit 77b1aff186
2 changed files with 164 additions and 0 deletions

View file

@ -477,6 +477,36 @@ LINPHONE_PUBLIC char * linphone_presence_service_get_contact(const LinphonePrese
*/
LINPHONE_PUBLIC int linphone_presence_service_set_contact(LinphonePresenceService *service, const char *contact);
/**
* @brief Gets the number of notes included in the presence service.
* @param[in] service The #LinphonePresenceService object to get the number of notes from.
* @return The number of notes included in the #LinphonePresenceService object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_service_nb_notes(const LinphonePresenceService *service);
/**
* @brief Gets the nth note of a presence service.
* @param[in] service The #LinphonePresenceService object to get the note from.
* @param[in] idx The index of the note to get (the first note having the index 0).
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
*/
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePresenceService *service, unsigned int idx);
/**
* @brief Adds a note to a presence service.
* @param[in] service The #LinphonePresenceService object for which to add a note.
* @param[in] note The #LinphonePresenceNote object to add to the service.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_service_add_note(LinphonePresenceService *service, LinphonePresenceNote *note);
/**
* @brief Clears the notes of a presence service.
* @param[in] service The #LinphonePresenceService object for which to clear the notes.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_service_clear_notes(LinphonePresenceService *service);
/*****************************************************************************
* PRESENCE PERSON FUNCTIONS TO GET ACCESS TO ALL FUNCTIONALITIES *
@ -536,6 +566,65 @@ LINPHONE_PUBLIC int linphone_presence_person_add_activity(LinphonePresencePerson
*/
LINPHONE_PUBLIC int linphone_presence_person_clear_activities(LinphonePresencePerson *person);
/**
* @brief Gets the number of notes included in the presence person.
* @param[in] person The #LinphonePresencePerson object to get the number of notes from.
* @return The number of notes included in the #LinphonePresencePerson object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_notes(const LinphonePresencePerson *person);
/**
* @brief Gets the nth note of a presence person.
* @param[in] person The #LinphonePresencePerson object to get the note from.
* @param[in] idx The index of the note to get (the first note having the index 0).
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
*/
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx);
/**
* @brief Adds a note to a presence person.
* @param[in] person The #LinphonePresencePerson object for which to add a note.
* @param[in] note The #LinphonePresenceNote object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_person_add_note(LinphonePresencePerson *person, LinphonePresenceNote *note);
/**
* @brief Clears the notes of a presence person.
* @param[in] person The #LinphonePresencePerson object for which to clear the notes.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_person_clear_notes(LinphonePresencePerson *person);
/**
* @brief Gets the number of activities notes included in the presence person.
* @param[in] person The #LinphonePresencePerson object to get the number of activities notes from.
* @return The number of activities notes included in the #LinphonePresencePerson object.
*/
LINPHONE_PUBLIC unsigned int linphone_presence_person_nb_activities_notes(const LinphonePresencePerson *person);
/**
* @brief Gets the nth activities note of a presence person.
* @param[in] person The #LinphonePresencePerson object to get the activities note from.
* @param[in] idx The index of the activities note to get (the first note having the index 0).
* @return A pointer to a #LinphonePresenceNote object if successful, NULL otherwise.
*/
LINPHONE_PUBLIC LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx);
/**
* @brief Adds an activities note to a presence person.
* @param[in] person The #LinphonePresencePerson object for which to add an activities note.
* @param[in] note The #LinphonePresenceNote object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note);
/**
* @brief Clears the activities notes of a presence person.
* @param[in] person The #LinphonePresencePerson object for which to clear the activities notes.
* @return 0 if successful, a value < 0 in case of error.
*/
LINPHONE_PUBLIC int linphone_presence_person_clear_activites_notes(LinphonePresencePerson *person);
/*****************************************************************************

View file

@ -783,6 +783,32 @@ int linphone_presence_service_set_contact(LinphonePresenceService *service, cons
return 0;
}
unsigned int linphone_presence_service_nb_notes(const LinphonePresenceService *service) {
return ms_list_size(service->notes);
}
LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePresenceService *service, unsigned int idx) {
if ((service == NULL) || (idx >= linphone_presence_service_nb_notes(service)))
return NULL;
return (LinphonePresenceNote *)ms_list_nth_data(service->notes, idx);
}
int linphone_presence_service_add_person(LinphonePresenceService *service, LinphonePresenceNote *note) {
if ((service == NULL) || (note == NULL)) return -1;
service->notes = ms_list_append(service->notes, note);
return 0;
}
int linphone_presence_service_clear_notes(LinphonePresenceService *service) {
if (service == NULL) return -1;
ms_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref);
ms_list_free(service->notes);
service->notes = NULL;
return 0;
}
/*****************************************************************************
@ -834,6 +860,55 @@ int linphone_presence_person_clear_activities(LinphonePresencePerson *person) {
return 0;
}
unsigned int linphone_presence_person_nb_notes(const LinphonePresencePerson *person) {
if (person == NULL) return 0;
return ms_list_size(person->notes);
}
LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx) {
if ((person == NULL) || (idx >= linphone_presence_person_nb_notes(person)))
return NULL;
return (LinphonePresenceNote *)ms_list_nth_data(person->notes, idx);
}
int linphone_presence_person_add_note(LinphonePresencePerson *person, LinphonePresenceNote *note) {
if ((person == NULL) || (note == NULL)) return -1;
person->notes = ms_list_append(person->notes, note);
return 0;
}
int linphone_presence_person_clear_notes(LinphonePresencePerson *person) {
if (person == NULL) return -1;
ms_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref);
ms_list_free(person->notes);
person->notes = NULL;
return 0;
}
unsigned int linphone_presence_person_nb_activities_notes(const LinphonePresencePerson *person) {
if (person == NULL) return 0;
return ms_list_size(person->activities_notes);
}
LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx) {
if ((person == NULL) || (idx >= linphone_presence_person_nb_activities_notes(person)))
return NULL;
return (LinphonePresenceNote *)ms_list_nth_data(person->activities_notes, idx);
}
int linphone_presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note) {
if ((person == NULL) || (note == NULL)) return -1;
person->notes = ms_list_append(person->activities_notes, note);
return 0;
}
int linphone_presence_person_clear_activities_notes(LinphonePresencePerson *person) {
if (person == NULL) return -1;
ms_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref);
ms_list_free(person->activities_notes);
person->activities_notes = NULL;
return 0;
}
/*****************************************************************************