Fix phone (no sip) presence

Add pushpresence setting
This commit is contained in:
benoit.martins 2023-04-19 00:07:11 +02:00 committed by Benoit Martins
parent cd553df74e
commit 919cca1726
7 changed files with 51 additions and 25 deletions

View file

@ -74,25 +74,34 @@
NSDictionary* userInfo = notification.userInfo;
NSString* friend = (NSString*)userInfo[@"friend"];
self.tableView.indexPathsForVisibleRows;
NSArray<NSIndexPath *> *indexPathsVisible = self.tableView.indexPathsForVisibleRows;
for (int i = 0; i < addressBookMap.count; i++)
for (int i = 0; i < indexPathsVisible.count; i++)
{
/*
NSMutableArray *subAr = [addressBookMap objectForKey:[addressBookMap keyAtIndex:2]];
Contact *contact = subAr[1];
if (contact.friend != nil) {
char *curi = linphone_address_as_string_uri_only(linphone_friend_get_address(contact.friend));
NSString *uri = [NSString stringWithUTF8String:curi];
NSMutableArray *subAr = [addressBookMap objectForKey:[addressBookMap keyAtIndex:indexPathsVisible[i].section]];
Contact *contact = subAr[indexPathsVisible[i].row];
if([uri isEqual:friend]){
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:i inSection:0];
NSArray* indexArray = [NSArray arrayWithObjects:indexPath, nil];
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
}
}
*/
if (contact.sipAddresses.count > 0){
for (NSString *sip in contact.sipAddresses) {
NSString *uri = [@"sip:" stringByAppendingString:sip];
if([uri isEqual:friend]){
NSIndexPath* indexPath = indexPathsVisible[i];
NSArray* indexArray = [NSArray arrayWithObjects:indexPath, nil];
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
}
}
}else if (contact.phones.count > 0){
for (NSString *phone in contact.phones) {
NSString *uri = phone;
if([uri isEqual:friend]){
NSIndexPath* indexPath = indexPathsVisible[i];
NSArray* indexArray = [NSArray arrayWithObjects:indexPath, nil];
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
}
}
}
}
}
}

View file

@ -75,8 +75,12 @@
// To avoid crash
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
}
linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceBusy);
[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];
}
@ -89,7 +93,9 @@
[LinphoneManager.instance startLinphoneCore];
[LinphoneManager.instance.fastAddressBook reloadFriends];
linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceOnline);
if([LinphoneManager.instance lpConfigBoolForKey:@"account_push_presence_preference"]){
linphone_core_set_consolidated_presence(LC, LinphoneConsolidatedPresenceOnline);
}
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil];

View file

@ -155,6 +155,7 @@
// default values
{
[self setBool:NO forKey:@"account_pushnotification_preference"];
[self setBool:YES forKey:@"account_push_presence_preference"];
[self setObject:@"" forKey:@"account_mandatory_username_preference"];
[self setObject:@"" forKey:@"account_mandatory_domain_preference"];
[self setCString:"" forKey:@"account_display_name_preference"];
@ -184,6 +185,9 @@
{
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"];
[self setBool:pushPresenceEnabled forKey:@"account_push_presence_preference"];
const LinphoneAddress *identity_addr = linphone_account_params_get_identity_address(accountParams);
const char *server_addr = linphone_account_params_get_server_addr(accountParams);

View file

@ -137,7 +137,7 @@ class Avatar : UIView {
let avatarImageWihtoutPresence = UIImageView(image: shared?.toImage())
let contactAddress = Address.getSwiftObject(cObject: address).contact()
var iconPresenceView = UIImageView()
if contactAddress != nil {
if (contactAddress != nil) {
iconPresenceView = updatePresenceImage(contact: contactAddress!)
avatarWithPresence.addSubview(avatarImageWihtoutPresence)
@ -145,6 +145,8 @@ class Avatar : UIView {
iconPresenceView.frame = CGRect(x: 35, y: 35, width: 16, height: 16)
shared?.addDelegate(contactAddress: contactAddress!)
}else{
avatarWithPresence.addSubview(avatarImageWihtoutPresence)
}
return avatarWithPresence.toImage()
}
@ -162,13 +164,8 @@ class Avatar : UIView {
let avatarWithPresence = UIView(frame: CGRect(x: 0, y: 0, width: size, height: size))
let avatarImageWihtoutPresence = UIImageView(image: shared?.toImage())
let iconPresenceView = updatePresenceImage(contact: contact)
avatarWithPresence.addSubview(avatarImageWihtoutPresence)
avatarWithPresence.addSubview(iconPresenceView)
iconPresenceView.frame = CGRect(x: 35, y: 35, width: 16, height: 16)
shared?.addDelegate(contactAddress: contact)
return avatarWithPresence.toImage()
}

View file

@ -44,6 +44,16 @@
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Title</key>
<string>Push Presence</string>
<key>Key</key>
<string>account_push_presence_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>