forked from mirrors/linphone-iphone
factorize code to get or create a one to one chat room
This commit is contained in:
parent
7eabc1a842
commit
05597fc648
5 changed files with 21 additions and 35 deletions
|
|
@ -82,19 +82,9 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (void)createChatRoom {
|
||||
NSString *addr = _tableController.contactsGroup[0];
|
||||
const LinphoneAddress *local = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(LC));
|
||||
LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String);
|
||||
LinphoneChatRoom *room = linphone_core_find_one_to_one_chat_room(LC, local, linphoneAddress);
|
||||
if (!room) {
|
||||
bctbx_list_t *addresses = bctbx_list_new((void*)linphoneAddress);
|
||||
[PhoneMainView.instance createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT addresses:addresses andWaitView:_waitView];
|
||||
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
|
||||
return;
|
||||
}
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
[view setChatRoom:room];
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
linphone_address_destroy(linphoneAddress);
|
||||
LinphoneAddress *remoteAddress = linphone_address_new(addr.UTF8String);
|
||||
[PhoneMainView.instance getOrCreateOneToOneChatRoom:remoteAddress waitView:_waitView];
|
||||
linphone_address_unref(remoteAddress);
|
||||
}
|
||||
|
||||
#pragma mark - Buttons signals
|
||||
|
|
|
|||
|
|
@ -194,17 +194,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog);
|
||||
if (addr == NULL)
|
||||
return;
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
const LinphoneAddress *local = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(LC));
|
||||
LinphoneChatRoom *room = linphone_core_find_one_to_one_chat_room(LC, local, addr);
|
||||
if (!room) {
|
||||
bctbx_list_t *addresses = bctbx_list_new((void*)addr);
|
||||
[PhoneMainView.instance createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT addresses:addresses andWaitView:_waitView];
|
||||
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
|
||||
return;
|
||||
}
|
||||
[view setChatRoom:room];
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
|
||||
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -138,17 +138,7 @@
|
|||
if (addr == NULL)
|
||||
return;
|
||||
|
||||
const LinphoneAddress *local = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(LC));
|
||||
LinphoneChatRoom *room = linphone_core_find_one_to_one_chat_room(LC, local, addr);
|
||||
if (!room) {
|
||||
bctbx_list_t *addresses = bctbx_list_new(addr);
|
||||
[PhoneMainView.instance createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT addresses:addresses andWaitView:_waitView];
|
||||
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
|
||||
return;
|
||||
}
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
[view setChatRoom:room];
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView];
|
||||
linphone_address_destroy(addr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@
|
|||
- (BOOL)removeInhibitedEvent:(id)event;
|
||||
|
||||
- (void)updateApplicationBadgeNumber;
|
||||
- (void)getOrCreateOneToOneChatRoom:(const LinphoneAddress *)remoteAddress waitView:(UIView *)waitView;
|
||||
- (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView;
|
||||
+ (PhoneMainView*) instance;
|
||||
|
||||
|
|
|
|||
|
|
@ -859,6 +859,20 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
|
||||
#pragma mark - Chat room Functions
|
||||
|
||||
- (void) getOrCreateOneToOneChatRoom:(const LinphoneAddress *)remoteAddress waitView:(UIView *)waitView {
|
||||
const LinphoneAddress *local = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(LC));
|
||||
LinphoneChatRoom *room = linphone_core_find_one_to_one_chat_room(LC, local, remoteAddress);
|
||||
if (!room) {
|
||||
bctbx_list_t *addresses = bctbx_list_new((void*)remoteAddress);
|
||||
[self createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT addresses:addresses andWaitView:waitView];
|
||||
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
|
||||
return;
|
||||
}
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
[view setChatRoom:room];
|
||||
[self changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
- (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView {
|
||||
_waitView = waitView;
|
||||
_waitView.hidden = NO;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue