mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 17:29:20 +00:00
Add linphone_presence_model_get_timestamp() function.
This commit is contained in:
parent
bbd8ec8ba4
commit
9609991767
3 changed files with 39 additions and 0 deletions
|
|
@ -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, ×tamp);
|
||||
ms_list_for_each2(model->persons, (MSIterate2Func)presence_person_find_newer_timestamp, ×tamp);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue