diff --git a/coreapi/linphonepresence.h b/coreapi/linphonepresence.h index 7a38e6b3d..9e650c6ce 100644 --- a/coreapi/linphonepresence.h +++ b/coreapi/linphonepresence.h @@ -389,11 +389,12 @@ 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. * @returns The created presence service, NULL on error. * * The created presence service has the basic status 'closed'. */ -LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_service_new(void); +LINPHONE_PUBLIC LinphonePresenceService * linphone_presence_service_new(const char *id); /** * @brief Gets the basic status of a presence service. diff --git a/coreapi/presence.c b/coreapi/presence.c index 6e0e3ef11..ac4319df9 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -354,7 +354,7 @@ 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(); + service = linphone_presence_service_new(NULL); if (service == NULL) return -1; if (linphone_presence_service_set_basic_status(service, basic_status) < 0) return -1; @@ -403,7 +403,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(); + service = linphone_presence_service_new(NULL); if (service == NULL) return -1; linphone_presence_model_add_service(model, service); } @@ -708,11 +708,16 @@ int linphone_presence_model_clear_services(LinphonePresenceModel *model) { * PRESENCE SERVICE FUNCTIONS TO GET ACCESS TO ALL FUNCTIONALITIES * ****************************************************************************/ -LinphonePresenceService * linphone_presence_service_new(void) { +LinphonePresenceService * linphone_presence_service_new(const char *id) { LinphonePresenceService *service; - char *id = generate_presence_id(); - service = presence_service_new(id, LinphonePresenceBasicStatusClosed); - ms_free(id); + char *service_id; + if (id == NULL) + service_id = generate_presence_id(); + else + service_id = ms_strdup(id); + service = presence_service_new(service_id, LinphonePresenceBasicStatusClosed); + if (service_id != NULL) + ms_free(service_id); return service; }