More coherent API for linphone_presence_service_new().

This commit is contained in:
Ghislain MARY 2013-09-10 12:59:52 +02:00
parent 439f922310
commit 5c7159d87f
2 changed files with 8 additions and 6 deletions

View file

@ -390,11 +390,13 @@ LINPHONE_PUBLIC int linphone_presence_model_clear_services(LinphonePresenceModel
/**
* @brief Creates a presence service.
* @param[in] id The id of the presence service to be created. Can be NULL to generate it automatically.
* @param[in] basic_status The #LinphonePresenceBasicStatus to set for the #LinphonePresenceService object.
* @param[in] contact The contact string to set.
* @returns The created presence service, NULL on error.
*
* The created presence service has the basic status 'closed'.
*/
LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_service_new(const char *id);
LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_service_new(const char *id, LinphonePresenceBasicStatus, const char *contact);
/**
* @brief Gets the basic status of a presence service.

View file

@ -354,10 +354,9 @@ int linphone_presence_model_set_basic_status(LinphonePresenceModel *model, Linph
if (model == NULL) return -1;
linphone_presence_model_clear_services(model);
service = linphone_presence_service_new(NULL);
service = linphone_presence_service_new(NULL, basic_status, NULL);
if (service == NULL) return -1;
if (linphone_presence_service_set_basic_status(service, basic_status) < 0) return -1;
if (linphone_presence_model_add_service(model, service) < 0) return -1;
return 0;
}
@ -403,7 +402,7 @@ int linphone_presence_model_set_contact(LinphonePresenceModel *model, const char
service = linphone_presence_model_get_nth_service(model, 0);
if (service == NULL) {
service = linphone_presence_service_new(NULL);
service = linphone_presence_service_new(NULL, LinphonePresenceBasicStatusClosed, NULL);
if (service == NULL) return -1;
linphone_presence_model_add_service(model, service);
}
@ -708,14 +707,15 @@ int linphone_presence_model_clear_services(LinphonePresenceModel *model) {
* PRESENCE SERVICE FUNCTIONS TO GET ACCESS TO ALL FUNCTIONALITIES *
****************************************************************************/
LinphonePresenceService * linphone_presence_service_new(const char *id) {
LinphonePresenceService * linphone_presence_service_new(const char *id, LinphonePresenceBasicStatus basic_status, const char *contact) {
LinphonePresenceService *service;
char *service_id;
if (id == NULL)
service_id = generate_presence_id();
else
service_id = ms_strdup(id);
service = presence_service_new(service_id, LinphonePresenceBasicStatusClosed);
service = presence_service_new(service_id, basic_status);
linphone_presence_service_set_contact(service, contact);
if (service_id != NULL)
ms_free(service_id);
return service;