forked from mirrors/linphone-iphone
Fix memory leaks.
This commit is contained in:
parent
bac9d2b98e
commit
8315ac543e
9 changed files with 51 additions and 31 deletions
|
|
@ -99,10 +99,12 @@
|
|||
|
||||
- (void) buildChatContactTable {
|
||||
|
||||
bctbx_list_t *results = [MagicSearchSingleton.instance getLastSearchResults];
|
||||
while (results) {
|
||||
|
||||
LinphoneSearchResult *result = results->data;
|
||||
bctbx_list_t *result_list = [MagicSearchSingleton.instance getLastSearchResults];
|
||||
bctbx_list_t *it;
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
|
||||
for (it = result_list; it != NULL; it = it->next) {
|
||||
LinphoneSearchResult *result = it->data;
|
||||
const LinphoneAddress *addr = linphone_search_result_get_address(result);
|
||||
const LinphoneFriend* friend = linphone_search_result_get_friend(result);
|
||||
const char *phoneNumber = linphone_search_result_get_phone_number(result);
|
||||
|
|
@ -110,6 +112,7 @@
|
|||
Contact *contact = nil;
|
||||
char *uri = nil;
|
||||
NSString *address = nil;
|
||||
|
||||
if (addr) {
|
||||
uri = linphone_address_as_string_uri_only(addr);
|
||||
address = [NSString stringWithUTF8String:uri];
|
||||
|
|
@ -122,40 +125,37 @@
|
|||
}
|
||||
} else if (friend){
|
||||
if (!phoneNumber) {
|
||||
results = results->next;
|
||||
continue;
|
||||
}
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
|
||||
if (account) {
|
||||
const char *normalizedPhoneNumber = linphone_account_normalize_phone_number(account, phoneNumber);
|
||||
char *normalizedPhoneNumber = linphone_account_normalize_phone_number(account, phoneNumber);
|
||||
if (!normalizedPhoneNumber) {
|
||||
// get invalid phone number, continue
|
||||
results = results->next;
|
||||
continue;
|
||||
}
|
||||
addr = linphone_account_normalize_sip_uri(account, normalizedPhoneNumber);
|
||||
bctbx_free(normalizedPhoneNumber);
|
||||
uri = linphone_address_as_string_uri_only(addr);
|
||||
address = [NSString stringWithUTF8String:uri];
|
||||
|
||||
contact = [[Contact alloc] initWithFriend:friend];
|
||||
[contact setCreatedFromLdapOrProvisioning:TRUE];
|
||||
[_ldapAndProvisioningContactAddressBookMap setObject:contact forKey:address];
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
}
|
||||
if (uri) ms_free(uri);
|
||||
|
||||
if (!addr) {
|
||||
results = results->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
ms_free(uri);
|
||||
|
||||
[_addresses addObject:address];
|
||||
[_phoneOrAddr addObject:phoneNumber ? [NSString stringWithUTF8String:phoneNumber] : address];
|
||||
[_addressesCached addObject:[NSString stringWithFormat:@"%d",linphone_search_result_get_capabilities(result)]];
|
||||
|
||||
results = results->next;
|
||||
}
|
||||
bctbx_list_free(result_list);
|
||||
[self.tableView reloadData];
|
||||
_reloadMagicSearch = FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,6 +348,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[_tableController scrollToBottom:true];
|
||||
}
|
||||
}
|
||||
if (peerAddr) linphone_address_unref(peerAddr);
|
||||
if (localAddr) linphone_address_unref(localAddr);
|
||||
|
||||
_backButton.hidden = _tableController.isEditing;
|
||||
[self refreshImageDrawer];
|
||||
|
|
@ -418,6 +420,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL;
|
||||
const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom);
|
||||
[ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr];
|
||||
bctbx_list_free(participants);
|
||||
} else
|
||||
_addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT];
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc {
|
||||
bctbx_list_free(_data);
|
||||
}
|
||||
|
||||
#pragma mark - ViewController Functions
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
|
|
|
|||
|
|
@ -64,9 +64,13 @@
|
|||
}
|
||||
const char *key = [NSString stringWithFormat:@"ab%@", acncontact.identifier].UTF8String;
|
||||
// try to find friend associated with that person
|
||||
if (_friend){
|
||||
linphone_friend_unref(_friend);
|
||||
_friend = nil;
|
||||
}
|
||||
_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));
|
||||
_friend = 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) {
|
||||
|
|
@ -85,9 +89,7 @@
|
|||
linphone_friend_set_inc_subscribe_policy(_friend, LinphoneSPDeny);
|
||||
linphone_core_add_friend(LC, _friend);
|
||||
}
|
||||
}
|
||||
linphone_friend_ref(_friend);
|
||||
|
||||
}else linphone_friend_ref(_friend);
|
||||
} else if (_friend) {
|
||||
[self loadFriend];
|
||||
} else {
|
||||
|
|
@ -461,7 +463,7 @@
|
|||
// 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));
|
||||
_friend = 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) {
|
||||
|
|
@ -480,11 +482,11 @@
|
|||
linphone_friend_set_inc_subscribe_policy(_friend, LinphoneSPDeny);
|
||||
linphone_core_add_friend(LC, _friend);
|
||||
}
|
||||
}
|
||||
linphone_friend_ref(_friend);
|
||||
} else linphone_friend_ref(_friend);
|
||||
}
|
||||
|
||||
- (void)clearFriend {
|
||||
if (_friend) linphone_friend_unref(_friend);
|
||||
_friend = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1920,8 +1920,10 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
[self checkLocalNetworkPermission];
|
||||
// For OutgoingCall, show CallOutgoingView
|
||||
BOOL initiateVideoCall = linphone_core_get_video_activation_policy(LC) && linphone_video_activation_policy_get_automatically_initiate(linphone_core_get_video_activation_policy(LC));
|
||||
LinphoneVideoActivationPolicy *policy = linphone_core_get_video_activation_policy(LC);
|
||||
BOOL initiateVideoCall = linphone_video_activation_policy_get_automatically_initiate(policy);
|
||||
[CallManager.instance startCallWithAddr:iaddr isSas:FALSE isVideo:initiateVideoCall isConference:false];
|
||||
linphone_video_activation_policy_unref(policy);
|
||||
}
|
||||
|
||||
#pragma mark - Misc Functions
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@
|
|||
} else {
|
||||
_addressLabel.text = [NSString stringWithUTF8String:LINPHONE_DUMMY_SUBJECT];
|
||||
}
|
||||
bctbx_list_free(participants);
|
||||
} else {
|
||||
const char *subject = linphone_chat_room_get_subject(chatRoom);
|
||||
_addressLabel.text = [NSString stringWithUTF8String:subject ?: LINPHONE_DUMMY_SUBJECT];
|
||||
|
|
|
|||
|
|
@ -711,7 +711,7 @@ import AVFoundation
|
|||
}
|
||||
break
|
||||
case .Released:
|
||||
call.userData = nil
|
||||
CallManager.setAppData(sCall : call, appData : nil);
|
||||
break
|
||||
case .Referred:
|
||||
CallManager.instance().referedFromCall = call.callLog?.callId
|
||||
|
|
|
|||
|
|
@ -89,17 +89,20 @@
|
|||
|
||||
if (!contact) {
|
||||
LinphoneFriend *friend = linphone_core_find_friend(LC, address);
|
||||
MSList *numbers = linphone_friend_get_phone_numbers(friend);
|
||||
while (numbers) {
|
||||
NSString *phone = [NSString stringWithUTF8String:numbers->data];
|
||||
bctbx_list_t *number_list = linphone_friend_get_phone_numbers(friend);
|
||||
bctbx_list_t *it;
|
||||
for (it = number_list ; it != NULL; it = it->next) {
|
||||
NSString *phone = [NSString stringWithUTF8String:it->data];
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
|
||||
if (account) {
|
||||
const char *normvalue = linphone_account_normalize_phone_number(account, phone.UTF8String);
|
||||
char *normvalue = linphone_account_normalize_phone_number(account, phone.UTF8String);
|
||||
LinphoneAddress *addr = linphone_account_normalize_sip_uri(account, normvalue);
|
||||
char *phone_addr = linphone_address_as_string_uri_only(addr);
|
||||
contact = [FastAddressBook getContact:[NSString stringWithUTF8String:phone_addr]];
|
||||
ms_free(phone_addr);
|
||||
linphone_address_unref(addr);
|
||||
bctbx_free(normvalue);
|
||||
} else {
|
||||
contact = [FastAddressBook getContact:phone];
|
||||
}
|
||||
|
|
@ -107,8 +110,8 @@
|
|||
if (contact) {
|
||||
break;
|
||||
}
|
||||
numbers = numbers->next;
|
||||
}
|
||||
bctbx_list_free(number_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -467,14 +467,15 @@
|
|||
return NULL;
|
||||
|
||||
LinphoneAccount *account = linphone_core_get_default_account(LC);
|
||||
const char *normvalue;
|
||||
char *normvalue;
|
||||
normvalue = linphone_account_is_phone_number(account, value.UTF8String)
|
||||
? linphone_account_normalize_phone_number(account, value.UTF8String)
|
||||
: value.UTF8String;
|
||||
: bctbx_strdup(value.UTF8String);
|
||||
|
||||
LinphoneAddress *addr = linphone_account_normalize_sip_uri(account, normvalue);
|
||||
// first try to find a friend with the given address
|
||||
Contact *c = [FastAddressBook getContactWithAddress:addr];
|
||||
bctbx_free(normvalue);
|
||||
|
||||
if (c && c.friend) {
|
||||
LinphoneFriend *f = c.friend;
|
||||
|
|
@ -496,8 +497,11 @@
|
|||
// numbers by default
|
||||
if (addr && account) {
|
||||
const char *username = linphone_account_params_get_dial_escape_plus_enabled(linphone_account_get_params(account)) ? normvalue : value.UTF8String;
|
||||
if (linphone_account_is_phone_number(account, username))
|
||||
linphone_address_set_username(addr, linphone_account_normalize_phone_number(account, username));
|
||||
if (linphone_account_is_phone_number(account, username)){
|
||||
char *normalized = linphone_account_normalize_phone_number(account, username);
|
||||
linphone_address_set_username(addr, normalized);
|
||||
bctbx_free(normalized);
|
||||
}
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue