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

Fix bug 0001391: An incorrect presence activity is added if not is contained...

Fix bug 0001391: An incorrect presence activity is added if not is contained in a received presence XML.
parent 6e686b4c
......@@ -3986,48 +3986,55 @@ LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc){
const char *description = NULL;
activity = linphone_presence_model_get_activity(lc->presence_model);
description = linphone_presence_activity_get_description(activity);
switch (linphone_presence_activity_get_type(activity)) {
case LinphonePresenceActivityOffline:
return LinphoneStatusOffline;
case LinphonePresenceActivityOnline:
if (activity) {
description = linphone_presence_activity_get_description(activity);
switch (linphone_presence_activity_get_type(activity)) {
case LinphonePresenceActivityOffline:
return LinphoneStatusOffline;
case LinphonePresenceActivityOnline:
return LinphoneStatusOnline;
case LinphonePresenceActivityBusy:
if (description != NULL) {
if (strcmp(description, "Do not disturb") == 0)
return LinphoneStatusDoNotDisturb;
else if (strcmp(description, "Using another messaging service") == 0)
return LinphoneStatusAltService;
}
return LinphoneStatusBusy;
case LinphonePresenceActivityInTransit:
case LinphonePresenceActivitySteering:
return LinphoneStatusBeRightBack;
case LinphonePresenceActivityAway:
return LinphoneStatusAway;
case LinphonePresenceActivityOnThePhone:
return LinphoneStatusOnThePhone;
case LinphonePresenceActivityBreakfast:
case LinphonePresenceActivityDinner:
case LinphonePresenceActivityLunch:
case LinphonePresenceActivityMeal:
return LinphoneStatusOutToLunch;
case LinphonePresenceActivityPermanentAbsence:
return LinphoneStatusMoved;
case LinphonePresenceActivityOther:
if (description != NULL) {
if (strcmp(description, "Waiting for user acceptance") == 0)
return LinphoneStatusPending;
}
return LinphoneStatusBusy;
case LinphonePresenceActivityVacation:
return LinphoneStatusVacation;
case LinphonePresenceActivityAppointment:
case LinphonePresenceActivityMeeting:
case LinphonePresenceActivityWorship:
return LinphoneStatusDoNotDisturb;
default:
return LinphoneStatusBusy;
}
} else {
if (linphone_presence_model_get_basic_status(lc->presence_model) == LinphonePresenceBasicStatusOpen)
return LinphoneStatusOnline;
case LinphonePresenceActivityBusy:
if (description != NULL) {
if (strcmp(description, "Do not disturb") == 0)
return LinphoneStatusDoNotDisturb;
else if (strcmp(description, "Using another messaging service") == 0)
return LinphoneStatusAltService;
}
return LinphoneStatusBusy;
case LinphonePresenceActivityInTransit:
case LinphonePresenceActivitySteering:
return LinphoneStatusBeRightBack;
case LinphonePresenceActivityAway:
return LinphoneStatusAway;
case LinphonePresenceActivityOnThePhone:
return LinphoneStatusOnThePhone;
case LinphonePresenceActivityBreakfast:
case LinphonePresenceActivityDinner:
case LinphonePresenceActivityLunch:
case LinphonePresenceActivityMeal:
return LinphoneStatusOutToLunch;
case LinphonePresenceActivityPermanentAbsence:
return LinphoneStatusMoved;
case LinphonePresenceActivityOther:
if (description != NULL) {
if (strcmp(description, "Waiting for user acceptance") == 0)
return LinphoneStatusPending;
}
return LinphoneStatusBusy;
case LinphonePresenceActivityVacation:
return LinphoneStatusVacation;
case LinphonePresenceActivityAppointment:
case LinphonePresenceActivityMeeting:
case LinphonePresenceActivityWorship:
return LinphoneStatusDoNotDisturb;
default:
return LinphoneStatusBusy;
else
return LinphoneStatusOffline;
}
}
......
......@@ -1574,28 +1574,6 @@ void linphone_notify_parse_presence(const char *content_type, const char *conten
ms_error("Unknown content type '%s/%s' for presence", content_type, content_subtype);
}
/* If no activities are present in the model, add a dummy activity so that linphone_presence_activity_get_type() returns
* the expected result. */
if (model != NULL) {
LinphonePresenceActivity *activity = linphone_presence_model_get_activity(model);
if (activity == NULL) {
LinphonePresenceBasicStatus basic_status = linphone_presence_model_get_basic_status(model);
LinphonePresenceActivityType acttype;
switch (basic_status) {
case LinphonePresenceBasicStatusOpen:
acttype = LinphonePresenceActivityOnline;
break;
case LinphonePresenceBasicStatusClosed:
default:
acttype = LinphonePresenceActivityOffline;
break;
}
activity = linphone_presence_activity_new(acttype, NULL);
linphone_presence_model_add_activity(model, activity);
linphone_presence_activity_unref(activity);
}
}
*result = (SalPresenceModel *)model;
}
......
......@@ -68,68 +68,75 @@ void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) {
} else {
ms_error("Unexpected basic status [%i]",linphone_presence_model_get_basic_status(counters->last_received_presence));
}
for (i=0;counters->last_received_presence&&i<linphone_presence_model_get_nb_activities(counters->last_received_presence); i++) {
LinphonePresenceActivity *activity = linphone_presence_model_get_nth_activity(counters->last_received_presence, i);
switch (linphone_presence_activity_get_type(activity)) {
case LinphonePresenceActivityOffline:
counters->number_of_LinphonePresenceActivityOffline++; break;
case LinphonePresenceActivityOnline:
counters->number_of_LinphonePresenceActivityOnline++; break;
case LinphonePresenceActivityAppointment:
counters->number_of_LinphonePresenceActivityAppointment++; break;
case LinphonePresenceActivityAway:
counters->number_of_LinphonePresenceActivityAway++; break;
case LinphonePresenceActivityBreakfast:
counters->number_of_LinphonePresenceActivityBreakfast++; break;
case LinphonePresenceActivityBusy:
counters->number_of_LinphonePresenceActivityBusy++; break;
case LinphonePresenceActivityDinner:
counters->number_of_LinphonePresenceActivityDinner++; break;
case LinphonePresenceActivityHoliday:
counters->number_of_LinphonePresenceActivityHoliday++; break;
case LinphonePresenceActivityInTransit:
counters->number_of_LinphonePresenceActivityInTransit++; break;
case LinphonePresenceActivityLookingForWork:
counters->number_of_LinphonePresenceActivityLookingForWork++; break;
case LinphonePresenceActivityLunch:
counters->number_of_LinphonePresenceActivityLunch++; break;
case LinphonePresenceActivityMeal:
counters->number_of_LinphonePresenceActivityMeal++; break;
case LinphonePresenceActivityMeeting:
counters->number_of_LinphonePresenceActivityMeeting++; break;
case LinphonePresenceActivityOnThePhone:
counters->number_of_LinphonePresenceActivityOnThePhone++; break;
case LinphonePresenceActivityOther:
counters->number_of_LinphonePresenceActivityOther++; break;
case LinphonePresenceActivityPerformance:
counters->number_of_LinphonePresenceActivityPerformance++; break;
case LinphonePresenceActivityPermanentAbsence:
counters->number_of_LinphonePresenceActivityPermanentAbsence++; break;
case LinphonePresenceActivityPlaying:
counters->number_of_LinphonePresenceActivityPlaying++; break;
case LinphonePresenceActivityPresentation:
counters->number_of_LinphonePresenceActivityPresentation++; break;
case LinphonePresenceActivityShopping:
counters->number_of_LinphonePresenceActivityShopping++; break;
case LinphonePresenceActivitySleeping:
counters->number_of_LinphonePresenceActivitySleeping++; break;
case LinphonePresenceActivitySpectator:
counters->number_of_LinphonePresenceActivitySpectator++; break;
case LinphonePresenceActivitySteering:
counters->number_of_LinphonePresenceActivitySteering++; break;
case LinphonePresenceActivityTravel:
counters->number_of_LinphonePresenceActivityTravel++; break;
case LinphonePresenceActivityTV:
counters->number_of_LinphonePresenceActivityTV++; break;
case LinphonePresenceActivityUnknown:
counters->number_of_LinphonePresenceActivityUnknown++; break;
case LinphonePresenceActivityVacation:
counters->number_of_LinphonePresenceActivityVacation++; break;
case LinphonePresenceActivityWorking:
counters->number_of_LinphonePresenceActivityWorking++; break;
case LinphonePresenceActivityWorship:
counters->number_of_LinphonePresenceActivityWorship++; break;
if (linphone_presence_model_get_nb_activities(counters->last_received_presence) > 0) {
for (i=0;counters->last_received_presence&&i<linphone_presence_model_get_nb_activities(counters->last_received_presence); i++) {
LinphonePresenceActivity *activity = linphone_presence_model_get_nth_activity(counters->last_received_presence, i);
switch (linphone_presence_activity_get_type(activity)) {
case LinphonePresenceActivityOffline:
counters->number_of_LinphonePresenceActivityOffline++; break;
case LinphonePresenceActivityOnline:
counters->number_of_LinphonePresenceActivityOnline++; break;
case LinphonePresenceActivityAppointment:
counters->number_of_LinphonePresenceActivityAppointment++; break;
case LinphonePresenceActivityAway:
counters->number_of_LinphonePresenceActivityAway++; break;
case LinphonePresenceActivityBreakfast:
counters->number_of_LinphonePresenceActivityBreakfast++; break;
case LinphonePresenceActivityBusy:
counters->number_of_LinphonePresenceActivityBusy++; break;
case LinphonePresenceActivityDinner:
counters->number_of_LinphonePresenceActivityDinner++; break;
case LinphonePresenceActivityHoliday:
counters->number_of_LinphonePresenceActivityHoliday++; break;
case LinphonePresenceActivityInTransit:
counters->number_of_LinphonePresenceActivityInTransit++; break;
case LinphonePresenceActivityLookingForWork:
counters->number_of_LinphonePresenceActivityLookingForWork++; break;
case LinphonePresenceActivityLunch:
counters->number_of_LinphonePresenceActivityLunch++; break;
case LinphonePresenceActivityMeal:
counters->number_of_LinphonePresenceActivityMeal++; break;
case LinphonePresenceActivityMeeting:
counters->number_of_LinphonePresenceActivityMeeting++; break;
case LinphonePresenceActivityOnThePhone:
counters->number_of_LinphonePresenceActivityOnThePhone++; break;
case LinphonePresenceActivityOther:
counters->number_of_LinphonePresenceActivityOther++; break;
case LinphonePresenceActivityPerformance:
counters->number_of_LinphonePresenceActivityPerformance++; break;
case LinphonePresenceActivityPermanentAbsence:
counters->number_of_LinphonePresenceActivityPermanentAbsence++; break;
case LinphonePresenceActivityPlaying:
counters->number_of_LinphonePresenceActivityPlaying++; break;
case LinphonePresenceActivityPresentation:
counters->number_of_LinphonePresenceActivityPresentation++; break;
case LinphonePresenceActivityShopping:
counters->number_of_LinphonePresenceActivityShopping++; break;
case LinphonePresenceActivitySleeping:
counters->number_of_LinphonePresenceActivitySleeping++; break;
case LinphonePresenceActivitySpectator:
counters->number_of_LinphonePresenceActivitySpectator++; break;
case LinphonePresenceActivitySteering:
counters->number_of_LinphonePresenceActivitySteering++; break;
case LinphonePresenceActivityTravel:
counters->number_of_LinphonePresenceActivityTravel++; break;
case LinphonePresenceActivityTV:
counters->number_of_LinphonePresenceActivityTV++; break;
case LinphonePresenceActivityUnknown:
counters->number_of_LinphonePresenceActivityUnknown++; break;
case LinphonePresenceActivityVacation:
counters->number_of_LinphonePresenceActivityVacation++; break;
case LinphonePresenceActivityWorking:
counters->number_of_LinphonePresenceActivityWorking++; break;
case LinphonePresenceActivityWorship:
counters->number_of_LinphonePresenceActivityWorship++; break;
}
}
} else {
if (linphone_presence_model_get_basic_status(counters->last_received_presence) == LinphonePresenceBasicStatusOpen)
counters->number_of_LinphonePresenceActivityOnline++;
else
counters->number_of_LinphonePresenceActivityOffline++;
}
}
......
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