mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
refresh friends from fastaddressbook when going from BG to FG
This commit is contained in:
parent
b841f611f2
commit
db3495a33d
5 changed files with 56 additions and 5 deletions
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
- (instancetype)initWithCNContact:(CNContact *)contact;
|
||||
- (instancetype)initWithFriend:(LinphoneFriend *) friend;
|
||||
- (void)reloadFriend;
|
||||
- (void)clearFriend;
|
||||
|
||||
- (BOOL)setSipAddress:(NSString *)sip atIndex:(NSInteger)index;
|
||||
- (BOOL)setEmail:(NSString *)email atIndex:(NSInteger)index;
|
||||
|
|
|
|||
|
|
@ -455,4 +455,36 @@
|
|||
_emails = [[NSMutableArray alloc] init];
|
||||
}
|
||||
|
||||
- (void)reloadFriend {
|
||||
const char *key = [NSString stringWithFormat:@"ab%@", _person.identifier].UTF8String;
|
||||
// try to find friend associated with that person
|
||||
_friend = linphone_friend_list_find_friend_by_ref_key(linphone_core_get_default_friend_list(LC), key);
|
||||
if (!_friend) {
|
||||
_friend = linphone_friend_ref(linphone_core_create_friend(LC));
|
||||
linphone_friend_set_ref_key(_friend, key);
|
||||
linphone_friend_set_name(_friend, [NSString stringWithFormat:@"%@%@", _firstName ? _firstName : @"", _lastName ? [_firstName ? @" " : @"" stringByAppendingString:_lastName] : @""] .UTF8String);
|
||||
for (NSString *sipAddr in _sipAddresses) {
|
||||
LinphoneAddress *addr = linphone_core_interpret_url(LC, sipAddr.UTF8String);
|
||||
if (addr) {
|
||||
linphone_address_set_display_name(addr, [self displayName].UTF8String);
|
||||
linphone_friend_add_address(_friend, addr);
|
||||
linphone_address_destroy(addr);
|
||||
}
|
||||
}
|
||||
for (NSString *phone in _phones) {
|
||||
linphone_friend_add_phone_number(_friend, phone.UTF8String);
|
||||
}
|
||||
if (_friend) {
|
||||
linphone_friend_enable_subscribes(_friend, FALSE);
|
||||
linphone_friend_set_inc_subscribe_policy(_friend, LinphoneSPDeny);
|
||||
linphone_core_add_friend(LC, _friend);
|
||||
}
|
||||
}
|
||||
linphone_friend_ref(_friend);
|
||||
}
|
||||
|
||||
- (void)clearFriend {
|
||||
_friend = NULL;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -58,12 +58,13 @@
|
|||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
LOGI(@"%@", NSStringFromSelector(_cmd));
|
||||
[LinphoneManager.instance enterBackgroundMode];
|
||||
|
||||
[LinphoneManager.instance.fastAddressBook clearFriends];
|
||||
[CoreManager.instance stopLinphoneCore];
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
[LinphoneManager.instance startLinphoneCore];
|
||||
[LinphoneManager.instance.fastAddressBook reloadFriends];
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil];
|
||||
}
|
||||
|
||||
|
|
@ -100,9 +101,9 @@
|
|||
if (PhoneMainView.instance.currentView == ContactsListView.compositeViewDescription || PhoneMainView.instance.currentView == ContactDetailsView.compositeViewDescription) {
|
||||
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
|
||||
}
|
||||
[instance.fastAddressBook fetchContactsInBackGroundThread];
|
||||
instance.fastAddressBook.needToUpdate = FALSE;
|
||||
}
|
||||
[instance.fastAddressBook fetchContactsInBackGroundThread];
|
||||
instance.fastAddressBook.needToUpdate = FALSE;
|
||||
}
|
||||
|
||||
LinphoneCall *call = linphone_core_get_current_call(LC);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@
|
|||
@property(readonly, nonatomic) NSMutableDictionary *addressBookMap;
|
||||
@property BOOL needToUpdate;
|
||||
|
||||
- (void) fetchContactsInBackGroundThread;
|
||||
- (void)fetchContactsInBackGroundThread;
|
||||
- (BOOL)deleteContact:(Contact *)contact;
|
||||
- (BOOL)deleteCNContact:(CNContact *)CNContact;
|
||||
- (BOOL)deleteAllContacts;
|
||||
- (BOOL)saveContact:(Contact *)contact;
|
||||
- (BOOL)saveCNContact:(CNContact *)CNContact contact:(Contact *)Contact;
|
||||
- (void)reloadFriends;
|
||||
- (void)clearFriends;
|
||||
|
||||
- (void)dumpContactsDisplayNamesToUserDefaults;
|
||||
- (void)removeContactFromUserDefaults:(Contact *)contact;
|
||||
|
|
|
|||
|
|
@ -498,6 +498,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)reloadFriends {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[_addressBookMap enumerateKeysAndObjectsUsingBlock:^(NSString *name, Contact *contact, BOOL *stop) {
|
||||
[contact reloadFriend];
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)clearFriends {
|
||||
[_addressBookMap enumerateKeysAndObjectsUsingBlock:^(NSString *name, Contact *contact, BOOL *stop) {
|
||||
[contact clearFriend];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)dumpContactsDisplayNamesToUserDefaults {
|
||||
LOGD(@"dumpContactsDisplayNamesToUserDefaults");
|
||||
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:kLinphoneMsgNotificationAppGroupId];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue