Fix publish presence setting

Add log_collection_upload_server_url and update_presence_model_timestamp_before_publish_expires_refresh in LinphoneRC
Add publish and pusblish_expires in assistant_linphone.rc (create and existing)
This commit is contained in:
Benoit Martins 2023-04-20 16:24:46 +02:00
parent 919cca1726
commit bff4491da7
10 changed files with 80 additions and 19 deletions

View file

@ -63,6 +63,9 @@
- (void)applicationDidEnterBackground:(UIApplication *)application {
LOGI(@"%@", NSStringFromSelector(_cmd));
if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){
linphone_core_set_consolidated_presence([LinphoneManager getLc], LinphoneConsolidatedPresenceBusy);
}
if (linphone_core_get_global_state(LC) != LinphoneGlobalOff) {
[LinphoneManager.instance enterBackgroundMode];
[LinphoneManager.instance.fastAddressBook clearFriends];
@ -75,12 +78,6 @@
// To avoid crash
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
}
[LinphoneManager.instance lpConfigSetBool:FALSE forKey:@"account_push_presence_preference"];
if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){
linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceBusy);
}
[CallManager.instance stopLinphoneCore];
}
@ -92,9 +89,9 @@
[LinphoneManager.instance startLinphoneCore];
[LinphoneManager.instance.fastAddressBook reloadFriends];
[AvatarBridge clearFriends];
if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){
linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceOnline);
linphone_core_set_consolidated_presence([LinphoneManager getLc], LinphoneConsolidatedPresenceOnline);
}
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil];

View file

@ -186,7 +186,7 @@
BOOL pushEnabled = linphone_account_params_get_push_notification_allowed(accountParams);
[self setBool:pushEnabled forKey:@"account_pushnotification_preference"];
BOOL pushPresenceEnabled = [LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"];
BOOL pushPresenceEnabled = linphone_account_params_get_publish_enabled(accountParams);
[self setBool:pushPresenceEnabled forKey:@"account_push_presence_preference"];
const LinphoneAddress *identity_addr = linphone_account_params_get_identity_address(accountParams);
@ -618,6 +618,7 @@
if (username && [username length] > 0 && domain && [domain length] > 0) {
int expire = [self integerForKey:@"account_expire_preference"];
BOOL pushnotification = [self boolForKey:@"account_pushnotification_preference"];
BOOL publishPrensence = [self boolForKey:@"account_push_presence_preference"];
NSString *prefix = [self stringForKey:@"account_prefix_preference"];
BOOL use_prefix = [self boolForKey:@"apply_international_prefix_for_calls_and_chats"];
NSString *proxyAddress = [self stringForKey:@"account_proxy_preference"];
@ -698,7 +699,10 @@
// use empty string "" instead of NULL to avoid being overwritten by default proxy config values
linphone_account_params_set_push_notification_allowed(newAccountParams, pushnotification);
linphone_account_params_set_remote_push_notification_allowed(newAccountParams, pushnotification);
linphone_account_params_set_publish_enabled(newAccountParams, publishPrensence);
[LinphoneManager.instance lpConfigSetBool:publishPrensence forKey:@"account_push_presence_preference"];
linphone_account_params_set_register_enabled(newAccountParams, is_enabled);
linphone_account_params_set_avpf_mode(newAccountParams, use_avpf);
linphone_account_params_set_expires(newAccountParams, expire);

View file

@ -381,6 +381,10 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
}
- (void)migrationLinphoneSettings {
NSString *appDomain = [LinphoneManager.instance lpConfigStringForKey:@"domain_name"
inSection:@"app"
withDefault:@"sip.linphone.org"];
/* AVPF migration */
if ([self lpConfigBoolForKey:@"avpf_migration_done"] == FALSE) {
const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
@ -473,6 +477,26 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
}
[self lpConfigSetBool:TRUE forKey:@"push_notification_migration_done"];
}
if ([self lpConfigBoolForKey:@"publish_enabled_migration_done"] == FALSE) {
const MSList *accounts = linphone_core_get_account_list(theLinphoneCore);
linphone_core_set_log_collection_upload_server_url(LC, "https://www.linphone.org:444/lft.php");
[self lpConfigSetBool:TRUE forKey:@"update_presence_model_timestamp_before_publish_expires_refresh"];
while (accounts)
{
LinphoneAccount *account = (LinphoneAccount *)accounts->data;
LinphoneAccountParams *newAccountParams = linphone_account_params_clone(linphone_account_get_params(account));
if (strcmp(appDomain.UTF8String, linphone_account_params_get_domain(newAccountParams)) == 0) {
linphone_account_params_set_publish_enabled(newAccountParams, true);
linphone_account_params_set_publish_expires(newAccountParams, 120);
linphone_account_set_params(account, newAccountParams);
}
linphone_account_params_unref(newAccountParams);
accounts = accounts->next;
}
[self lpConfigSetBool:TRUE forKey:@"publish_enabled_migration_done"];
}
}
- (void)migrationPerAccount {

View file

@ -1118,6 +1118,14 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
// retrieve linphone logs if available
char *filepath = linphone_core_compress_log_collection();
LinphoneCoreCbs *coreCbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_log_collection_upload_state_changed(coreCbs, core_log_collection_upload_state_changed);
linphone_core_add_callbacks(LC, coreCbs);
linphone_core_upload_log_collection(LC);
if (filepath != NULL) {
NSString *filename = [[NSString stringWithUTF8String:filepath] componentsSeparatedByString:@"/"].lastObject;
NSString *mimeType = nil;
@ -1165,6 +1173,17 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
[self emailAttachments:attachments];
}
void core_log_collection_upload_state_changed(LinphoneCore *core, LinphoneCoreLogCollectionUploadState state , const char* info) {
LOGD(@"LinphoneCoreLogCollectionUploadStateDelivered core_log_collection_upload_state_changed %s", info);
if (state == LinphoneCoreLogCollectionUploadStateDelivered) {
LOGD(@"LinphoneCoreLogCollectionUploadStateDelivered %s", info);
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = [NSString stringWithUTF8String: info];
}
}
- (void)sendEmailWithPrivacyAttachments {
NSMutableArray *attachments = [[NSMutableArray alloc] initWithCapacity:4];

View file

@ -101,8 +101,9 @@ class Avatar : UIView {
friend.append(Friend.getSwiftObject(cObject: (contactAddress.friend)!))
let newFriendDelegate = FriendDelegateStub(
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
let presenceModel = linphoneFriend.getPresenceModelForUriOrTel(uriOrTel: (linphoneFriend.address?.asStringUriOnly())!)
NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.isOnline])
NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.consolidatedPresence.rawValue == LinphoneConsolidatedPresenceOnline.rawValue])
}
)
friendDelegate.append(newFriendDelegate)
@ -138,13 +139,15 @@ class Avatar : UIView {
let contactAddress = Address.getSwiftObject(cObject: address).contact()
var iconPresenceView = UIImageView()
if (contactAddress != nil) {
iconPresenceView = updatePresenceImage(contact: contactAddress!)
shared?.addDelegate(contactAddress: contactAddress!)
iconPresenceView = updatePresenceImage(contact: contactAddress!)
avatarWithPresence.addSubview(avatarImageWihtoutPresence)
avatarWithPresence.addSubview(iconPresenceView)
iconPresenceView.frame = CGRect(x: 35, y: 35, width: 16, height: 16)
shared?.addDelegate(contactAddress: contactAddress!)
}else{
avatarWithPresence.addSubview(avatarImageWihtoutPresence)
}
@ -183,13 +186,22 @@ class Avatar : UIView {
presenceModel = friend.getPresenceModelForUriOrTel(uriOrTel: (friend.address?.asStringUriOnly())!)
hasPresence = presenceModel != nil && presenceModel!.basicStatus == PresenceBasicStatus.Open
}
if (hasPresence! && presenceModel?.consolidatedPresence == ConsolidatedPresence.Online) {
imageName = "led_connected";
} else {
} else if (hasPresence! && presenceModel?.consolidatedPresence == ConsolidatedPresence.Busy){
imageName = "led_inprogress";
}
} else {
imageName = "";
}
return UIImageView(image: UIImage(named:imageName))
}
@objc static func clearFriends(){
if shared != nil {
shared!.friend = []
shared!.friendDelegate = []
}
}
}

View file

@ -4,6 +4,7 @@
<section name="proxy_default_values">
<entry name="dial_escape_plus" overwrite="true">0</entry>
<entry name="publish" overwrite="true">0</entry>
<entry name="publish_expires" overwrite="true">-1</entry>
<entry name="reg_expires" overwrite="true">3600</entry>
<entry name="reg_identity" overwrite="true"></entry>
<entry name="reg_proxy" overwrite="true"></entry>

View file

@ -4,7 +4,8 @@
<section name="proxy_default_values">
<entry name="avpf" overwrite="true">1</entry>
<entry name="dial_escape_plus" overwrite="true">0</entry>
<entry name="publish" overwrite="true">0</entry>
<entry name="publish" overwrite="true">1</entry>
<entry name="publish_expires" overwrite="true">120</entry>
<entry name="quality_reporting_collector" overwrite="true">sip:voip-metrics@sip.linphone.org;transport=tls</entry>
<entry name="quality_reporting_enabled" overwrite="true">1</entry>
<entry name="quality_reporting_interval" overwrite="true">180</entry>

View file

@ -3,7 +3,8 @@
<section name="proxy_default_values">
<entry name="avpf" overwrite="true">1</entry>
<entry name="dial_escape_plus" overwrite="true">0</entry>
<entry name="publish" overwrite="true">0</entry>
<entry name="publish" overwrite="true">1</entry>
<entry name="publish_expires" overwrite="true">120</entry>
<entry name="quality_reporting_collector" overwrite="true">sip:voip-metrics@sip.linphone.org;transport=tls</entry>
<entry name="quality_reporting_enabled" overwrite="true">1</entry>
<entry name="quality_reporting_interval" overwrite="true">180</entry>

View file

@ -50,6 +50,7 @@ reg_expires=1314000
[misc]
file_transfer_server_url=https://www.linphone.org:444/lft.php
log_collection_upload_server_url=https://www.linphone.org:444/lft.php
real_early_media=1
prefer_basic_chat_room=-1
conference_layout=1
@ -69,6 +70,7 @@ video_jitt_comp=60
video_rtp_port=9200-9299
[sip]
update_presence_model_timestamp_before_publish_expires_refresh=1
contact="Linphone iPhone" <sip:linphone.iphone@unknown-host>
guess_hostname=1
inc_timeout=45