forked from mirrors/linphone-iphone
Better presence detection
This commit is contained in:
parent
520f2d8d1f
commit
2e8de3d321
8 changed files with 58 additions and 14 deletions
|
|
@ -162,9 +162,9 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph
|
|||
linphone_proxy_config_set_dial_prefix(cfg, prefix[0] == '+' ? &prefix[1] : prefix);
|
||||
linphone_proxy_config_done(cfg);
|
||||
}
|
||||
[LinphoneManager.instance.fastAddressBook reload];
|
||||
[PhoneMainView.instance popToView:DialerView.compositeViewDescription];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneAddressBookUpdate object:NULL];
|
||||
[LinphoneManager.instance.fastAddressBook reload];
|
||||
} else {
|
||||
[thiz showErrorPopup:resp];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,8 +258,8 @@
|
|||
if (_person) {
|
||||
ret = [self addInProperty:kABPersonPhoneProperty value:(__bridge CFTypeRef)(phone)];
|
||||
} else {
|
||||
char *cphone =
|
||||
linphone_proxy_config_normalize_phone_number(NULL, phone.UTF8String) ?: ms_strdup(phone.UTF8String);
|
||||
char *cphone = ms_strdup(phone.UTF8String);
|
||||
// linphone_proxy_config_normalize_phone_number(NULL, phone.UTF8String) ?: ms_strdup(phone.UTF8String);
|
||||
if (cphone) {
|
||||
linphone_friend_add_phone_number(_friend, cphone);
|
||||
phone = [NSString stringWithUTF8String:cphone];
|
||||
|
|
@ -354,12 +354,12 @@
|
|||
NSInteger index = ABMultiValueGetIndexForIdentifier(map, identifier);
|
||||
if (index != -1) {
|
||||
NSString *valueRef = CFBridgingRelease(ABMultiValueCopyValueAtIndex(map, index));
|
||||
char *normalizedPhone = linphone_proxy_config_normalize_phone_number(
|
||||
linphone_core_get_default_proxy_config(LC), valueRef.UTF8String);
|
||||
if (normalizedPhone) {
|
||||
valueRef = [NSString stringWithUTF8String:normalizedPhone];
|
||||
ms_free(normalizedPhone);
|
||||
}
|
||||
// char *normalizedPhone = linphone_proxy_config_normalize_phone_number(
|
||||
// linphone_core_get_default_proxy_config(LC), valueRef.UTF8String);
|
||||
// if (normalizedPhone) {
|
||||
// valueRef = [NSString stringWithUTF8String:normalizedPhone];
|
||||
// ms_free(normalizedPhone);
|
||||
//}
|
||||
|
||||
[_phoneNumbers addObject:valueRef];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,6 +186,14 @@
|
|||
_editButton.hidden = TRUE;
|
||||
_deleteButton.hidden = TRUE;
|
||||
}
|
||||
|
||||
// Update presence for contact
|
||||
for (NSInteger j = 0; j < [self.tableController.tableView numberOfSections]; ++j) {
|
||||
for (NSInteger i = 0; i < [self.tableController.tableView numberOfRowsInSection:j]; ++i) {
|
||||
[(UIContactDetailsCell *)[self.tableController.tableView
|
||||
cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]] shouldHideLinphoneImageOfAddress];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deviceOrientationDidChange:(NSNotification*)notif {
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@
|
|||
|
||||
- (void)setContact:(Contact *)acontact {
|
||||
_contact = acontact;
|
||||
_linphoneImage.hidden = TRUE;
|
||||
if(_contact) {
|
||||
[ContactDisplay setDisplayNameLabel:_nameLabel forContact:_contact];
|
||||
_linphoneImage.hidden =
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
- (id)initWithIdentifier:(NSString *)identifier;
|
||||
- (void)setAddress:(NSString *)address;
|
||||
- (void)hideDeleteButton:(BOOL)hidden;
|
||||
- (void)shouldHideLinphoneImageOfAddress;
|
||||
|
||||
- (IBAction)onCallClick:(id)sender;
|
||||
- (IBAction)onChatClick:(id)sender;
|
||||
|
|
|
|||
|
|
@ -44,11 +44,12 @@
|
|||
|
||||
- (void)setAddress:(NSString *)address {
|
||||
_addressLabel.text = _editTextfield.text = address;
|
||||
char *normAddr = (char *)_addressLabel.text.UTF8String;
|
||||
if(_addressLabel.text && linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC), _addressLabel.text.UTF8String)) {
|
||||
char * normAddr = linphone_proxy_config_normalize_phone_number(linphone_core_get_default_proxy_config(LC), _addressLabel.text.UTF8String);
|
||||
_addressLabel.text = [NSString stringWithUTF8String:normAddr];
|
||||
normAddr = linphone_proxy_config_normalize_phone_number(linphone_core_get_default_proxy_config(LC),
|
||||
_addressLabel.text.UTF8String);
|
||||
}
|
||||
LinphoneAddress *addr = linphone_core_interpret_url(LC, _addressLabel.text.UTF8String);
|
||||
LinphoneAddress *addr = linphone_core_interpret_url(LC, normAddr);
|
||||
_chatButton.enabled = _callButton.enabled = (addr != NULL);
|
||||
|
||||
_chatButton.accessibilityLabel =
|
||||
|
|
@ -56,6 +57,39 @@
|
|||
_callButton.accessibilityLabel = [NSString stringWithFormat:NSLocalizedString(@"Call %@", nil), _addressLabel.text];
|
||||
// Test presence
|
||||
Contact* contact = [FastAddressBook getContactWithAddress:(addr)];
|
||||
|
||||
_linphoneImage.hidden = TRUE;
|
||||
if (contact) {
|
||||
self.linphoneImage.hidden =
|
||||
!((contact.friend &&
|
||||
linphone_presence_model_get_basic_status(linphone_friend_get_presence_model_for_uri_or_tel(
|
||||
contact.friend, _addressLabel.text.UTF8String)) == LinphonePresenceBasicStatusOpen) ||
|
||||
(!linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC),
|
||||
_addressLabel.text.UTF8String) &&
|
||||
[FastAddressBook isSipURIValid:_addressLabel.text]));
|
||||
}
|
||||
|
||||
if (addr) {
|
||||
linphone_address_destroy(addr);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)shouldHideLinphoneImageOfAddress {
|
||||
if (!_addressLabel.text) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *normAddr = (char *)_addressLabel.text.UTF8String;
|
||||
if (linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC),
|
||||
_addressLabel.text.UTF8String)) {
|
||||
normAddr = linphone_proxy_config_normalize_phone_number(linphone_core_get_default_proxy_config(LC),
|
||||
_addressLabel.text.UTF8String);
|
||||
}
|
||||
LinphoneAddress *addr = linphone_core_interpret_url(LC, normAddr);
|
||||
|
||||
// Test presence
|
||||
Contact *contact = [FastAddressBook getContactWithAddress:(addr)];
|
||||
|
||||
if (contact) {
|
||||
self.linphoneImage.hidden = ! ((contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model_for_uri_or_tel(contact.friend, _addressLabel.text.UTF8String)) == LinphonePresenceBasicStatusOpen) || (!linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC), _addressLabel.text.UTF8String) && [FastAddressBook isSipURIValid:_addressLabel.text]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@
|
|||
if (c && c.friend) {
|
||||
LinphoneFriend *f = c.friend;
|
||||
const LinphonePresenceModel *m =
|
||||
f ? linphone_friend_get_presence_model_for_uri_or_tel(f, normvalue) : NULL;
|
||||
f ? linphone_friend_get_presence_model_for_uri_or_tel(f, value.UTF8String) : NULL;
|
||||
const char *contact = m ? linphone_presence_model_get_contact(m) : NULL;
|
||||
if (contact) {
|
||||
LinphoneAddress *contact_addr = linphone_address_new(contact);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a14a8f9f2119fae927c1c36d64849ba64431759e
|
||||
Subproject commit 619f7bffd40d120c6e60fc00fcaa924baa78530b
|
||||
Loading…
Add table
Reference in a new issue