diff --git a/Classes/Base.lproj/ChatConversationCreateView.xib b/Classes/Base.lproj/ChatConversationCreateView.xib
index 2ef20c05f..04a42059e 100644
--- a/Classes/Base.lproj/ChatConversationCreateView.xib
+++ b/Classes/Base.lproj/ChatConversationCreateView.xib
@@ -19,7 +19,6 @@
-
@@ -145,18 +144,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Classes/Base.lproj/HistoryDetailsView.xib b/Classes/Base.lproj/HistoryDetailsView.xib
index 6104ac807..fa8b94115 100644
--- a/Classes/Base.lproj/HistoryDetailsView.xib
+++ b/Classes/Base.lproj/HistoryDetailsView.xib
@@ -1,8 +1,12 @@
-
-
+
+
+
+
+
-
+
+
@@ -80,7 +84,7 @@
-
+
@@ -96,14 +100,14 @@
-
+
-
+
-
+
@@ -138,37 +142,36 @@
-
+
-
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
diff --git a/Classes/Base.lproj/PhoneMainView.xib b/Classes/Base.lproj/PhoneMainView.xib
index 13d8cc75c..2844b95b9 100644
--- a/Classes/Base.lproj/PhoneMainView.xib
+++ b/Classes/Base.lproj/PhoneMainView.xib
@@ -1,8 +1,12 @@
-
-
+
+
+
+
+
-
+
+
@@ -10,6 +14,7 @@
+
@@ -24,23 +29,31 @@
-
-
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
diff --git a/Classes/ChatConversationCreateView.h b/Classes/ChatConversationCreateView.h
index 8b337f5ca..b2eb5a2e6 100644
--- a/Classes/ChatConversationCreateView.h
+++ b/Classes/ChatConversationCreateView.h
@@ -24,7 +24,6 @@
@property (weak, nonatomic) IBOutlet UIIconButton *allButton;
@property (weak, nonatomic) IBOutlet UIIconButton *linphoneButton;
@property (weak, nonatomic) IBOutlet UIImageView *selectedButtonImage;
-@property (weak, nonatomic) IBOutlet UIView *waitView;
@property(nonatomic) Boolean isForEditing;
diff --git a/Classes/ChatConversationCreateView.m b/Classes/ChatConversationCreateView.m
index 0a1484709..b31816f2a 100644
--- a/Classes/ChatConversationCreateView.m
+++ b/Classes/ChatConversationCreateView.m
@@ -58,7 +58,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- _waitView.hidden = YES;
if(_tableController.contactsGroup.count == 0) {
if (!_isForEditing)
_nextButton.enabled = FALSE;
@@ -76,40 +75,11 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark - Chat room functions
-void create_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
- ChatConversationCreateView *view = (__bridge ChatConversationCreateView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr));
- switch (newState) {
- case LinphoneChatRoomStateCreated:
- LOGI(@"Chat room [%p] created on server.", cr);
- [view onChatRoomCreated:cr];
- break;
- case LinphoneChatRoomStateCreationFailed:
- view.waitView.hidden = YES;
- [ChatConversationInfoView displayCreationError];
- LOGE(@"Chat room [%p] could not be created on server.", cr);
- break;
- default:
- break;
- }
-}
-
-- (void)onChatRoomCreated:(LinphoneChatRoom *)cr {
- ChatConversationView *view = VIEW(ChatConversationView);
- _waitView.hidden = YES;
- view.chatRoom = cr;
- [PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
-}
-
- (void)createChatRoom {
- _waitView.hidden = NO;
- LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, LINPHONE_DUMMY_SUBJECT);
NSString *addr = _tableController.contactsGroup[0];
LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String);
- LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(room);
- linphone_chat_room_cbs_set_state_changed(cbs, create_chat_room_state_changed);
- linphone_chat_room_cbs_set_user_data(cbs, (__bridge void*)self);
bctbx_list_t *addresses = bctbx_list_new((void *)linphoneAddress);
- linphone_chat_room_add_participants(room, addresses);
+ [PhoneMainView.instance createChatRoomWithSubject:LINPHONE_DUMMY_SUBJECT andAddresses:addresses];
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
}
diff --git a/Classes/ChatConversationInfoView.h b/Classes/ChatConversationInfoView.h
index a0c2b0fad..fa81175b2 100644
--- a/Classes/ChatConversationInfoView.h
+++ b/Classes/ChatConversationInfoView.h
@@ -27,7 +27,6 @@
@property (weak, nonatomic) IBOutlet UIIconButton *addButton;
@property (weak, nonatomic) IBOutlet UITextField *nameLabel;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
-@property (weak, nonatomic) IBOutlet UIView *waitView;
+ (void)displayCreationError;
diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m
index 81f9c465d..3f19cb241 100644
--- a/Classes/ChatConversationInfoView.m
+++ b/Classes/ChatConversationInfoView.m
@@ -74,7 +74,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- _waitView.hidden = YES;
_nameLabel.text = _room && linphone_chat_room_get_subject(_room)
? [NSString stringWithUTF8String:linphone_chat_room_get_subject(_room)]
: @"";
@@ -102,7 +101,7 @@ static UICompositeViewDescription *compositeDescription = nil;
if (_room) {
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(_room);
- linphone_chat_room_cbs_set_state_changed(cbs, chat_room_state_changed);
+ linphone_chat_room_cbs_set_state_changed(cbs, main_view_chat_room_state_changed);
linphone_chat_room_cbs_set_subject_changed(cbs, chat_room_subject_changed);
linphone_chat_room_cbs_set_participant_added(cbs, chat_room_participant_added);
linphone_chat_room_cbs_set_participant_removed(cbs, chat_room_participant_removed);
@@ -116,14 +115,6 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark - next functions
- (void)onCreate {
- _waitView.hidden = NO;
- LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, _nameLabel.text.UTF8String);
- if(!room) {
- return;
- }
- LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(room);
- linphone_chat_room_cbs_set_state_changed(cbs, chat_room_state_changed);
- linphone_chat_room_cbs_set_user_data(cbs, (__bridge void*)self);
bctbx_list_t *addresses = NULL;
for(NSString *addr in _contacts) {
LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String);
@@ -136,7 +127,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
addresses = bctbx_list_append(addresses, (void *)linphoneAddress);
}
- linphone_chat_room_add_participants(room, addresses);
+ [PhoneMainView.instance createChatRoomWithSubject:_nameLabel.text.UTF8String andAddresses:addresses];
bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
}
@@ -302,13 +293,6 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark - chat room callbacks
-- (void)goToChatRoom:(LinphoneChatRoom *)cr {
- _waitView.hidden = YES;
- ChatConversationView *view = VIEW(ChatConversationView);
- view.chatRoom = cr;
- [PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
-}
-
- (void)myAdminStatusChanged:(BOOL)admin {
NSString *message = admin
? NSLocalizedString(@"You are now an admin of the chat room", nil)
@@ -328,27 +312,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[PhoneMainView.instance presentViewController:alertView animated:YES completion:nil];
}
-void chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
- ChatConversationInfoView *view = (__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr));
- switch (newState) {
- case LinphoneChatRoomStateCreated:
- LOGI(@"Chat room [%p] created on server.", cr);
- [view goToChatRoom:cr];
- break;
- case LinphoneChatRoomStateCreationFailed:
- view.waitView.hidden = YES;
- [ChatConversationInfoView displayCreationError];
- LOGE(@"Chat room [%p] could not be created on server.", cr);
- break;
- case LinphoneChatRoomStateTerminated:
- LOGI(@"Chat room [%p] has been terminated.", cr);
- [view goToChatRoom:cr];
- break;
- default:
- break;
- }
-}
-
void chat_room_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
ChatConversationInfoView *view = (__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr));
view.nameLabel.text = [NSString stringWithUTF8String:linphone_event_log_get_subject(event_log)];
diff --git a/Classes/ChatConversationInfoView.xib b/Classes/ChatConversationInfoView.xib
index 86646888d..9463a7eea 100644
--- a/Classes/ChatConversationInfoView.xib
+++ b/Classes/ChatConversationInfoView.xib
@@ -18,7 +18,6 @@
-
@@ -148,18 +147,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m
index d33dbc4d7..47d59ad43 100644
--- a/Classes/HistoryDetailsView.m
+++ b/Classes/HistoryDetailsView.m
@@ -196,7 +196,14 @@ static UICompositeViewDescription *compositeDescription = nil;
if (addr == NULL)
return;
ChatConversationView *view = VIEW(ChatConversationView);
- LinphoneChatRoom *room = linphone_core_get_chat_room(LC, addr);
+ 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 andAddresses:addresses];
+ bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
+ return;
+ }
[view setChatRoom:room];
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
}
diff --git a/Classes/LinphoneUI/Base.lproj/UIContactDetailsCell.xib b/Classes/LinphoneUI/Base.lproj/UIContactDetailsCell.xib
index f695afd8c..ec69f4351 100644
--- a/Classes/LinphoneUI/Base.lproj/UIContactDetailsCell.xib
+++ b/Classes/LinphoneUI/Base.lproj/UIContactDetailsCell.xib
@@ -1,8 +1,11 @@
-
-
+
+
+
+
+
-
+
@@ -24,11 +27,11 @@
-
+
-
+
@@ -36,7 +39,7 @@
-
+
@@ -52,11 +55,11 @@
-
+
-
+
@@ -69,7 +72,7 @@
-
+
@@ -82,14 +85,14 @@
-
+
@@ -112,9 +115,4 @@
-
-
-
-
-
diff --git a/Classes/LinphoneUI/UIChatNotifiedEventCell.m b/Classes/LinphoneUI/UIChatNotifiedEventCell.m
index 81b401474..2d519167d 100644
--- a/Classes/LinphoneUI/UIChatNotifiedEventCell.m
+++ b/Classes/LinphoneUI/UIChatNotifiedEventCell.m
@@ -90,6 +90,16 @@ static const CGFloat NOTIFIED_CELL_HEIGHT = 44;
eventString = NSLocalizedString(formatedString, nil);
break;
}
+ case LinphoneEventLogTypeConferenceTerminated: {
+ NSString *formatedString = [NSString stringWithFormat:@"Chat room has been left"];
+ eventString = NSLocalizedString(formatedString, nil);
+ break;
+ }
+ case LinphoneEventLogTypeConferenceCreated: {
+ NSString *formatedString = [NSString stringWithFormat:@"Chat room has been entered"];
+ eventString = NSLocalizedString(formatedString, nil);
+ break;
+ }
default:
return;
}
diff --git a/Classes/LinphoneUI/UIContactDetailsCell.m b/Classes/LinphoneUI/UIContactDetailsCell.m
index 39b25a77d..08f0b3973 100644
--- a/Classes/LinphoneUI/UIContactDetailsCell.m
+++ b/Classes/LinphoneUI/UIContactDetailsCell.m
@@ -137,8 +137,16 @@
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:_addressLabel.text];
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 andAddresses:addresses];
+ bctbx_list_free_with_data(addresses, (void (*)(void *))linphone_address_unref);
+ return;
+ }
ChatConversationView *view = VIEW(ChatConversationView);
- LinphoneChatRoom *room = linphone_core_get_chat_room(LC, addr);
[view setChatRoom:room];
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
linphone_address_destroy(addr);
diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h
index c1049c4fc..86bef3cb5 100644
--- a/Classes/PhoneMainView.h
+++ b/Classes/PhoneMainView.h
@@ -86,6 +86,7 @@
@property(weak, readonly) UICompositeViewDescription *currentView;
@property LinphoneChatRoom* currentRoom;
@property(readonly, strong) MPVolumeView *volumeView;
+@property (weak, nonatomic) IBOutlet UIView *waitView;
- (void)changeCurrentView:(UICompositeViewDescription *)view;
- (UIViewController*)popCurrentView;
@@ -103,6 +104,9 @@
- (BOOL)removeInhibitedEvent:(id)event;
- (void)updateApplicationBadgeNumber;
+- (void)createChatRoomWithSubject:(const char *)subject andAddresses:(bctbx_list_t *)addresses;
+ (PhoneMainView*) instance;
@end
+
+void main_view_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState);
diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m
index d3cee0dc3..667715554 100644
--- a/Classes/PhoneMainView.m
+++ b/Classes/PhoneMainView.m
@@ -172,6 +172,7 @@ static RootViewManager *rootViewManagerInstance = nil;
}
- (void)viewWillAppear:(BOOL)animated {
+ _waitView.hidden = YES;
[super viewWillAppear:animated];
// Set observers
@@ -820,4 +821,46 @@ static RootViewManager *rootViewManagerInstance = nil;
linphone_call_terminate(call);
}
+#pragma mark - Chat room Functions
+
+- (void)createChatRoomWithSubject:(const char *)subject andAddresses:(bctbx_list_t *)addresses {
+ _waitView.hidden = NO;
+ LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, subject ?: LINPHONE_DUMMY_SUBJECT);
+ if (!room)
+ return;
+
+ LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(room);
+ linphone_chat_room_cbs_set_state_changed(cbs, main_view_chat_room_state_changed);
+ linphone_chat_room_cbs_set_user_data(cbs, (__bridge void*)self);
+ linphone_chat_room_add_participants(room, addresses);
+}
+
+- (void)goToChatRoom:(LinphoneChatRoom *)cr {
+ _waitView.hidden = YES;
+ ChatConversationView *view = VIEW(ChatConversationView);
+ view.chatRoom = cr;
+ [PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
+}
+
+void main_view_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
+ PhoneMainView *view = (__bridge PhoneMainView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr));
+ switch (newState) {
+ case LinphoneChatRoomStateCreated:
+ LOGI(@"Chat room [%p] created on server.", cr);
+ [view goToChatRoom:cr];
+ break;
+ case LinphoneChatRoomStateCreationFailed:
+ view.waitView.hidden = YES;
+ [ChatConversationInfoView displayCreationError];
+ LOGE(@"Chat room [%p] could not be created on server.", cr);
+ break;
+ case LinphoneChatRoomStateTerminated:
+ LOGI(@"Chat room [%p] has been terminated.", cr);
+ [view goToChatRoom:cr];
+ break;
+ default:
+ break;
+ }
+}
+
@end