create a chatroom with new configuration if it is an encryptrd chatroom

This commit is contained in:
Danmei Chen 2018-12-04 12:50:21 +01:00
parent 7f9cbd2a48
commit 2beaf5db15
11 changed files with 29 additions and 17 deletions

View file

@ -753,7 +753,8 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
- (IBAction)onChatClick:(id)sender {
const LinphoneCall *currentCall = linphone_core_get_current_call(LC);
const LinphoneAddress *addr = currentCall ? linphone_call_get_remote_address(currentCall) : NULL;
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView];
// TODO encrpted or unencrpted
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:TRUE];
}
- (IBAction)onRecordClick:(id)sender {

View file

@ -21,6 +21,7 @@
@property(nonatomic) Boolean isForEditing;
@property(nonatomic) Boolean isGroupChat;
@property(nonatomic) Boolean isEncrypted;
- (void) loadData;
@end

View file

@ -149,7 +149,7 @@
bctbx_list_t *addresses = NULL;
LinphoneAddress *addr = linphone_address_new(cell.addressLabel.text.UTF8String);
addresses = bctbx_list_append(addresses, addr);
[PhoneMainView.instance createChatRoomWithSubject:NULL addresses:addresses andWaitView:NULL];
[PhoneMainView.instance createChatRoomWithSubject:NULL addresses:addresses andWaitView:NULL isEncrypted:_isEncrypted];
linphone_address_unref(addr);
return;
}

View file

@ -32,6 +32,7 @@
@property(nonatomic) Boolean isForEditing;
@property(nonatomic) Boolean isGroupChat;
@property(nonatomic) Boolean isEncrypted;
- (IBAction)onBackClick:(id)sender;
- (IBAction)onNextClick:(id)sender;

View file

@ -50,6 +50,7 @@ static UICompositeViewDescription *compositeDescription = nil;
_tableController.collectionView = _collectionView;
_tableController.controllerNextButton = _nextButton;
_isForEditing = FALSE;
_isEncrypted = TRUE;
}
- (void)viewWillAppear:(BOOL)animated {
@ -86,6 +87,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[_collectionView reloadData];
_tableController.isForEditing = _isForEditing;
_tableController.isGroupChat = _isGroupChat;
_tableController.isEncrypted = _isEncrypted;
[self changeView:ContactsLinphone];
}
@ -94,7 +96,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)createChatRoom {
NSString *addr = _tableController.contactsGroup[0];
LinphoneAddress *remoteAddress = linphone_address_new(addr.UTF8String);
[PhoneMainView.instance getOrCreateOneToOneChatRoom:remoteAddress waitView:_waitView];
[PhoneMainView.instance getOrCreateOneToOneChatRoom:remoteAddress waitView:_waitView isEncrypted:_isEncrypted];
linphone_address_unref(remoteAddress);
}
@ -117,20 +119,23 @@ static UICompositeViewDescription *compositeDescription = nil;
ChatConversationInfoView *view = VIEW(ChatConversationInfoView);
view.contacts = _tableController.contactsGroup;
view.create = !_isForEditing;
view.encrypted = _isEncrypted;
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
}
- (IBAction)onChiffreClick:(id)sender {
CGRect frame = _chiffreButton.frame;
_isEncrypted = !_isEncrypted;
_tableController.isEncrypted = _isEncrypted;
// TODO show encrypted contacts
if (frame.origin.x > 10) {
if (_isEncrypted) {
// encrypted
frame.origin.x = 2;
[_chiffreImage setImage:[UIImage imageNamed:@"security_toogle_background_grey.png"]];
} else {
// no encrypted
frame.origin.x = 20;
[_chiffreImage setImage:[UIImage imageNamed:@"security_toogle_background_green.png"]];
} else {
// no encrypted
frame.origin.x = 2;
[_chiffreImage setImage:[UIImage imageNamed:@"security_toogle_background_grey.png"]];
}
_chiffreButton.frame = frame;
}

View file

@ -14,6 +14,7 @@
@property(nonatomic) BOOL create;
@property(nonatomic) BOOL imAdmin;
@property(nonatomic) BOOL encrypted;
@property(nonatomic, strong) NSMutableArray *contacts;
@property(nonatomic, strong) NSMutableArray *admins;
@property(nonatomic, strong) NSMutableArray *oldContacts;

View file

@ -142,7 +142,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
addresses = bctbx_list_append(addresses, (void *)linphoneAddress);
}
[PhoneMainView.instance createChatRoomWithSubject:_nameLabel.text.UTF8String addresses:addresses andWaitView:_waitView];
[PhoneMainView.instance createChatRoomWithSubject:_nameLabel.text.UTF8String addresses:addresses andWaitView:_waitView isEncrypted:_encrypted];
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
}

View file

@ -195,7 +195,8 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onChatClick:(id)event {
const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog);
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView];
// TODO one button for chatroom encrypted,another button for chatroom unencrypted
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:TRUE];
}
@end

View file

@ -137,7 +137,8 @@
- (IBAction)onChatClick:(id)event {
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:_addressLabel.text];
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView];
// TODO one button for chatroom encrypted,another button for chatroom unencrypted
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:TRUE];
linphone_address_destroy(addr);
}

View file

@ -112,8 +112,8 @@
- (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;
- (void)getOrCreateOneToOneChatRoom:(const LinphoneAddress *)remoteAddress waitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted;
- (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted;
- (void)goToChatRoom:(LinphoneChatRoom *)cr;
+ (PhoneMainView*) instance;

View file

@ -859,7 +859,7 @@ static RootViewManager *rootViewManagerInstance = nil;
#pragma mark - Chat room Functions
- (void)getOrCreateOneToOneChatRoom:(const LinphoneAddress *)remoteAddress waitView:(UIView *)waitView {
- (void)getOrCreateOneToOneChatRoom:(const LinphoneAddress *)remoteAddress waitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted{
if (!remoteAddress) {
[self changeCurrentView:ChatsListView.compositeViewDescription];
return;
@ -869,7 +869,7 @@ static RootViewManager *rootViewManagerInstance = nil;
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];
[self createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT addresses:addresses andWaitView:waitView isEncrypted:isEncrypted];
bctbx_list_free(addresses);
return;
}
@ -877,7 +877,7 @@ static RootViewManager *rootViewManagerInstance = nil;
[self goToChatRoom:room];
}
- (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView {
- (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted{
if (!linphone_proxy_config_get_conference_factory_uri(linphone_core_get_default_proxy_config(LC))
|| ([[LinphoneManager instance] lpConfigBoolForKey:@"prefer_basic_chat_room" inSection:@"misc"] && bctbx_list_size(addresses) == 1)) {
// If there's no factory uri, create a basic chat room
@ -902,7 +902,8 @@ static RootViewManager *rootViewManagerInstance = nil;
_waitView = waitView;
_waitView.hidden = NO;
LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, subject ?: LINPHONE_DUMMY_SUBJECT, bctbx_list_size(addresses) == 1);
// always use group chatroom
LinphoneChatRoom *room = linphone_core_create_client_group_chat_room_2(LC, subject ?: LINPHONE_DUMMY_SUBJECT, false, isEncrypted);
if (!room) {
_waitView.hidden = YES;
return;