Commit a4340fc4 authored by Ghislain MARY's avatar Ghislain MARY

Update documentation about presence.

parent b069a387
......@@ -359,11 +359,11 @@ LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){
return online_status;
}
LinphonePresenceModel * linphone_friend_get_presence(LinphoneFriend *lf) {
LinphonePresenceModel * linphone_friend_get_presence_model(LinphoneFriend *lf) {
return lf->presence;
}
void linphone_friend_set_presence(LinphoneFriend *lf, LinphonePresenceModel *model) {
void linphone_friend_set_presence_model(LinphoneFriend *lf, LinphonePresenceModel *model) {
if (lf->presence != NULL) {
linphone_presence_model_delete(lf->presence);
}
......
......@@ -51,9 +51,15 @@ static void stop(int signum){
* presence state change notification callback
*/
static void notify_presence_recv_updated (LinphoneCore *lc, LinphoneFriend *friend) {
LinphonePresenceActivity activity = LinphonePresenceActivityOffline;
const LinphonePresenceModel* model = linphone_friend_get_presence_model(friend);
const LinphoneAddress* friend_address = linphone_friend_get_address(friend);
printf("New state state [%s] for user id [%s] \n"
,linphone_online_status_to_string(linphone_friend_get_status(friend))
char *description = NULL;
linphone_presence_model_get_activity(model, &activity, &description);
printf("New state state [%s%s%s] for user id [%s] \n"
,linphone_presence_activity_to_string(activity)
,(description == NULL) ? "" : ": "
,(description == NULL) ? "" : description
,linphone_address_as_string (friend_address));
}
static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *friend, const char* url) {
......@@ -164,7 +170,8 @@ int main(int argc, char *argv[]){
}
linphone_core_set_presence_info(lc,0,NULL,LinphoneStatusOnline); /*set my status to online*/
/*set my status to online*/
linphone_core_set_presence_model(lc, 0, NULL, linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline, NULL));
/* main loop for receiving notifications and doing background linphone core work: */
while(running){
......@@ -172,7 +179,8 @@ int main(int argc, char *argv[]){
ms_usleep(50000);
}
linphone_core_set_presence_info(lc,0,NULL,LinphoneStatusOffline); /* change my presence status to offline*/
/* change my presence status to offline*/
linphone_core_set_presence_model(lc, 0, NULL, linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline, NULL));
linphone_core_iterate(lc); /* just to make sure new status is initiate message is issued */
linphone_friend_edit(my_friend); /* start editing friend */
......
......@@ -152,7 +152,7 @@ linphone_friend_done(my_friend); /*commit changes triggering an UNSUBSCRIBE mess
<b> Publishing presence status </b>
<br>Local presence status can be changed using function linphone_core_set_presence_info() .New status is propagated to all friends \link linphone_core_add_friend() previously added \endlink to #LinphoneCore.
<br>Local presence status can be changed using function linphone_core_set_presence_model() .New status is propagated to all friends \link linphone_core_add_friend() previously added \endlink to #LinphoneCore.
<b>Handling incoming subscription request</b>
<br> New incoming subscription requests are process according to \link linphone_friend_set_inc_subscribe_policy() the incoming subscription policy state \endlink for subscription initiated by \link linphone_core_add_friend() members of the buddy list. \endlink
......
......@@ -54,6 +54,7 @@ typedef enum {
/**
* Enum describing remote friend status
* @deprecated Use #LinphonePresenceModel and #LinphonePresenceActivity instead
*/
typedef enum _LinphoneOnlineStatus{
/**
......@@ -206,13 +207,26 @@ LINPHONE_PUBLIC void linphone_friend_done(LinphoneFriend *fr);
/**
* get friend status
* @brief Get the status of a friend
* @param[in] lf A #LinphoneFriend object
* @return #LinphoneOnlineStatus
* @deprecated Use linphone_friend_get_presence_model() instead
*/
LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
LinphonePresenceModel * linphone_friend_get_presence(LinphoneFriend *lf);
void linphone_friend_set_presence(LinphoneFriend *lf, LinphonePresenceModel *presence);
/**
* @brief Get the presence information of a friend
* @param[in] lf A #LinphoneFriend object
* @return A #LinphonePresenceModel object, or NULL if the friend to not have presence information (in which he is considered offline)
*/
LinphonePresenceModel * linphone_friend_get_presence_model(LinphoneFriend *lf);
/**
* @brief Set the presence information of a friend
* @param[in] lf A #LinphoneFriend object
* @param[in] presence A #LinphonePresenceModel object. It can be NULL to remove the presence information of the friend.
*/
void linphone_friend_set_presence_model(LinphoneFriend *lf, LinphonePresenceModel *presence);
BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
......@@ -222,41 +236,44 @@ bool_t linphone_friend_in_list(const LinphoneFriend *lf);
#define linphone_friend_url(lf) ((lf)->url)
/**
* return humain readable presence status
* Return humain readable presence status
* @param ss
* @deprecated Use #LinphonePresenceModel, #LinphonePresenceActivity and linphone_presence_activity_to_string() instead.
*/
const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
/**
* Set my presence status
* @param lc #LinphoneCore object
* @param minutes_away how long in away
* @param alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved
* @param os #LinphoneOnlineStatus
* @brief Set my presence status
* @param[in] lc #LinphoneCore object
* @param[in] minutes_away how long in away
* @param[in] alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved
* @param[in] os #LinphoneOnlineStatus
* @deprecated Use linphone_core_set_presence_model() instead
*/
LINPHONE_PUBLIC void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *alternative_contact,LinphoneOnlineStatus os);
/**
* Set my presence status
* @param lc #LinphoneCore object
* @param minutes_away how long in away
* @param alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved
* @param presence #LinphonePresenceModel
* @brief Set my presence status
* @param[in] lc #LinphoneCore object
* @param[in] minutes_away how long in away
* @param[in] alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved
* @param[in] presence #LinphonePresenceModel
*/
LINPHONE_PUBLIC void linphone_core_set_presence_model(LinphoneCore *lc, int minutes_away, const char *alternative_contact, LinphonePresenceModel *presence);
/**
* Get my presence status
* @param lc #LinphoneCore object
* @brief Get my presence status
* @param[in] lc #LinphoneCore object
* @return #LinphoneOnlineStatus
* @deprecated Use linphone_core_get_presence_model() instead
*/
LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);
/**
* Get my presence status
* @param lc #LinphoneCore object
* @return #LinphonePresenceModel
* @brief Get my presence status
* @param[in] lc #LinphoneCore object
* @return A #LinphonePresenceModel object, or NULL if no presence model has been set.
*/
LinphonePresenceModel * linphone_core_get_presence_model(const LinphoneCore *lc);
......
This diff is collapsed.
......@@ -945,6 +945,14 @@ static const char * presence_activity_to_string(LinphonePresenceActivity activit
return NULL;
}
const char * linphone_presence_activity_to_string(LinphonePresenceActivity activity) {
if (activity == LinphonePresenceActivityOffline)
return "offline";
if (activity == LinphonePresenceActivityOnline)
return "online";
return presence_activity_to_string(activity);
}
static int process_pidf_xml_presence_person_activities(xmlparsing_context_t *xml_ctx, struct _LinphonePresencePerson *person, unsigned int person_idx) {
char xpath_str[MAX_XPATH_LENGTH];
xmlXPathObjectPtr activities_nodes_object;
......@@ -1162,7 +1170,13 @@ void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf){
void linphone_core_notify_all_friends(LinphoneCore *lc, LinphonePresenceModel *presence){
MSList *elem;
ms_message("Notifying all friends");
LinphonePresenceActivity activity = LinphonePresenceActivityOffline;
char *description = NULL;
linphone_presence_model_get_activity(presence, &activity, &description);
ms_message("Notifying all friends that we are [%s%s%s]",
linphone_presence_activity_to_string(activity),
(description == NULL) ? "" : ": ",
(description == NULL) ? "" : description);
for(elem=lc->friends;elem!=NULL;elem=elem->next){
LinphoneFriend *lf=(LinphoneFriend *)elem->data;
if (lf->insub){
......@@ -1501,19 +1515,28 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
char *tmp;
LinphoneFriend *lf;
LinphoneAddress *friend=NULL;
LinphonePresenceModel *presence = (LinphonePresenceModel *)model;
lf=linphone_find_friend_by_out_subscribe(lc->friends,op);
if (lf!=NULL){
LinphonePresenceActivity activity = LinphonePresenceActivityOffline;
char *description = NULL;
friend=lf->uri;
tmp=linphone_address_as_string(friend);
linphone_friend_set_presence(lf, (LinphonePresenceModel *)model);
linphone_presence_model_get_activity(presence, &activity, &description);
ms_message("We are notified that [%s] has presence [%s%s%s]",
tmp,
linphone_presence_activity_to_string(activity),
(description == NULL) ? "" : ": ",
(description == NULL) ? "" : description);
linphone_friend_set_presence_model(lf, presence);
lf->subscribe_active=TRUE;
if (lc->vtable.notify_presence_recv)
lc->vtable.notify_presence_recv(lc,(LinphoneFriend*)lf);
ms_free(tmp);
}else{
ms_message("But this person is not part of our friend list, so we don't care.");
linphone_presence_model_delete((LinphonePresenceModel *)model);
linphone_presence_model_delete(presence);
}
if (ss==SalSubscribeTerminated){
sal_op_release(op);
......
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