Commit 96099917 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add linphone_presence_model_get_timestamp() function.

parent bbd8ec8b
......@@ -251,6 +251,13 @@ LINPHONE_PUBLIC bool_t linphone_presence_model_equals(const LinphonePresenceMode
*/
LINPHONE_PUBLIC LinphonePresenceBasicStatus linphone_presence_model_get_basic_status(const LinphonePresenceModel *model);
/**
* @brief Gets the timestamp of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the timestamp from.
* @return The timestamp of the #LinphonePresenceModel object or -1 on error.
*/
LINPHONE_PUBLIC time_t linphone_presence_model_get_timestamp(const LinphonePresenceModel *model);
/**
* @brief Gets the contact of a presence model.
* @param[in] model The #LinphonePresenceModel object to get the contact from.
......
......@@ -539,6 +539,28 @@ LinphonePresenceBasicStatus linphone_presence_model_get_basic_status(const Linph
return status;
}
static void presence_service_find_newer_timestamp(struct _LinphonePresenceService *service, time_t *timestamp) {
if (service->timestamp > *timestamp)
*timestamp = service->timestamp;
}
static void presence_person_find_newer_timestamp(struct _LinphonePresencePerson *person, time_t *timestamp) {
if (person->timestamp > *timestamp)
*timestamp = person->timestamp;
}
time_t linphone_presence_model_get_timestamp(const LinphonePresenceModel *model) {
time_t timestamp = (time_t)-1;
if (model == NULL)
return timestamp;
ms_list_for_each2(model->services, (MSIterate2Func)presence_service_find_newer_timestamp, &timestamp);
ms_list_for_each2(model->persons, (MSIterate2Func)presence_person_find_newer_timestamp, &timestamp);
return timestamp;
}
static void presence_model_find_contact(struct _LinphonePresenceService *service, char **contact) {
if ((service->contact != NULL) && (*contact == NULL))
*contact = service->contact;
......
......@@ -219,6 +219,7 @@ static void presence_information(void) {
const char *description = NULL;
const char *note_content = NULL;
char *contact2;
time_t current_timestamp, presence_timestamp;
CU_ASSERT_TRUE(subscribe_to_callee_presence(marie, pauline));
......@@ -278,6 +279,15 @@ static void presence_information(void) {
ms_free(contact2);
}
/* Presence timestamp. */
current_timestamp = time(NULL);
presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityShopping, NULL);
linphone_core_set_presence_model(pauline->lc, presence);
wait_core(marie->lc);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityShopping, 1);
presence_timestamp = linphone_presence_model_get_timestamp(presence);
CU_ASSERT_TRUE(presence_timestamp >= current_timestamp);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment