Replaced createClientGroupChatRoom method that is now deprecated by new one

This commit is contained in:
Sylvain Berfini 2019-03-19 17:11:39 +01:00
parent 9865ad9078
commit 0168b90b20
4 changed files with 89 additions and 42 deletions

View file

@ -52,6 +52,7 @@ import org.linphone.contacts.SearchContactsAdapter;
import org.linphone.core.Address; import org.linphone.core.Address;
import org.linphone.core.ChatRoom; import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomListenerStub; import org.linphone.core.ChatRoomListenerStub;
import org.linphone.core.ChatRoomParams;
import org.linphone.core.Core; import org.linphone.core.Core;
import org.linphone.core.FriendCapability; import org.linphone.core.FriendCapability;
import org.linphone.core.ProxyConfig; import org.linphone.core.ProxyConfig;
@ -565,15 +566,23 @@ public class ChatRoomCreationFragment extends Fragment
mChatRoom.getPeerAddress().asStringUriOnly(), mChatRoom.getPeerAddress().asStringUriOnly(),
mShareInfos); mShareInfos);
} else { } else {
mChatRoom = ChatRoomParams params = lc.createDefaultChatRoomParams();
lc.createClientGroupChatRoom( params.enableEncryption(true);
getString(R.string.dummy_group_chat_subject), params.enableGroup(true);
!createEncryptedChatRoom,
createEncryptedChatRoom);
mChatRoom.addListener(mChatRoomCreationListener);
Address participants[] = new Address[1]; Address participants[] = new Address[1];
participants[0] = address; participants[0] = address;
mChatRoom.addParticipants(participants);
mChatRoom =
lc.createChatRoom(
params,
getString(R.string.dummy_group_chat_subject),
participants);
if (mChatRoom != null) {
mChatRoom.addListener(mChatRoomCreationListener);
} else {
Log.w("[Chat Room Creation Fragment] createChatRoom returned null...");
}
} }
} else { } else {
if (lpc != null if (lpc != null
@ -582,13 +591,24 @@ public class ChatRoomCreationFragment extends Fragment
mChatRoom = lc.findOneToOneChatRoom(lpc.getIdentityAddress(), address, false); mChatRoom = lc.findOneToOneChatRoom(lpc.getIdentityAddress(), address, false);
if (mChatRoom == null) { if (mChatRoom == null) {
mWaitLayout.setVisibility(View.VISIBLE); mWaitLayout.setVisibility(View.VISIBLE);
mChatRoom =
lc.createClientGroupChatRoom( ChatRoomParams params = lc.createDefaultChatRoomParams();
getString(R.string.dummy_group_chat_subject), true); params.enableEncryption(false);
mChatRoom.addListener(mChatRoomCreationListener); params.enableGroup(true);
Address participants[] = new Address[1]; Address participants[] = new Address[1];
participants[0] = address; participants[0] = address;
mChatRoom.addParticipants(participants);
mChatRoom =
lc.createChatRoom(
params,
getString(R.string.dummy_group_chat_subject),
participants);
if (mChatRoom != null) {
mChatRoom.addListener(mChatRoomCreationListener);
} else {
Log.w("[Chat Room Creation Fragment] createChatRoom returned null...");
}
} else { } else {
LinphoneActivity.instance() LinphoneActivity.instance()
.goToChat( .goToChat(

View file

@ -51,6 +51,8 @@ import org.linphone.core.ChatMessage;
import org.linphone.core.ChatRoom; import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomListener; import org.linphone.core.ChatRoomListener;
import org.linphone.core.ChatRoomListenerStub; import org.linphone.core.ChatRoomListenerStub;
import org.linphone.core.ChatRoomParams;
import org.linphone.core.Core;
import org.linphone.core.EventLog; import org.linphone.core.EventLog;
import org.linphone.core.Participant; import org.linphone.core.Participant;
import org.linphone.core.tools.Log; import org.linphone.core.tools.Log;
@ -326,26 +328,28 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
public void onClick(View view) { public void onClick(View view) {
if (!mIsAlreadyCreatedGroup) { if (!mIsAlreadyCreatedGroup) {
mWaitLayout.setVisibility(View.VISIBLE); mWaitLayout.setVisibility(View.VISIBLE);
mTempChatRoom = Core core = LinphoneManager.getLc();
LinphoneManager.getLc()
.createClientGroupChatRoom(
mSubjectField.getText().toString(),
false,
mIsEncryptionEnabled);
mTempChatRoom.addListener(mChatRoomCreationListener);
if (mParticipants.size() == 1) {
// Ugly hack until new client chat group API so we can have a group
// chat room with 1 participant without being one to one
mTempChatRoom.addParticipant(mParticipants.get(0).getAddress());
} else {
int i = 0; int i = 0;
Address[] participantsToAdd = new Address[mParticipants.size()]; Address[] participants = new Address[mParticipants.size()];
for (ContactAddress ca : mParticipants) { for (ContactAddress ca : mParticipants) {
participantsToAdd[i] = ca.getAddress(); participants[i] = ca.getAddress();
i++; i++;
} }
mTempChatRoom.addParticipants(participantsToAdd);
ChatRoomParams params = core.createDefaultChatRoomParams();
params.enableEncryption(mIsEncryptionEnabled);
params.enableGroup(true);
mTempChatRoom =
core.createChatRoom(
params,
mSubjectField.getText().toString(),
participants);
if (mTempChatRoom != null) {
mTempChatRoom.addListener(mChatRoomCreationListener);
} else {
Log.w("[Group Info Fragment] createChatRoom returned null...");
} }
} else { } else {
// Subject // Subject

View file

@ -40,6 +40,7 @@ import org.linphone.R;
import org.linphone.core.Address; import org.linphone.core.Address;
import org.linphone.core.ChatRoom; import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomListenerStub; import org.linphone.core.ChatRoomListenerStub;
import org.linphone.core.ChatRoomParams;
import org.linphone.core.Core; import org.linphone.core.Core;
import org.linphone.core.Factory; import org.linphone.core.Factory;
import org.linphone.core.FriendCapability; import org.linphone.core.FriendCapability;
@ -105,15 +106,25 @@ public class ContactDetailsFragment extends Fragment
|| !LinphonePreferences.instance() || !LinphonePreferences.instance()
.useBasicChatRoomFor1To1())) { .useBasicChatRoomFor1To1())) {
mWaitLayout.setVisibility(View.VISIBLE); mWaitLayout.setVisibility(View.VISIBLE);
mChatRoom =
lc.createClientGroupChatRoom( ChatRoomParams params = lc.createDefaultChatRoomParams();
getString(R.string.dummy_group_chat_subject), params.enableEncryption(isSecured);
!isSecured, params.enableGroup(true);
isSecured);
mChatRoom.addListener(mChatRoomCreationListener);
Address participants[] = new Address[1]; Address participants[] = new Address[1];
participants[0] = participant; participants[0] = participant;
mChatRoom.addParticipants(participants);
mChatRoom =
lc.createChatRoom(
params,
getString(R.string.dummy_group_chat_subject),
participants);
if (mChatRoom != null) {
mChatRoom.addListener(mChatRoomCreationListener);
} else {
Log.w(
"[Contact Details Fragment] createChatRoom returned null...");
}
} else { } else {
room = lc.getChatRoom(participant); room = lc.getChatRoom(participant);
LinphoneActivity.instance() LinphoneActivity.instance()

View file

@ -36,6 +36,7 @@ import org.linphone.contacts.LinphoneContact;
import org.linphone.core.Address; import org.linphone.core.Address;
import org.linphone.core.ChatRoom; import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomListenerStub; import org.linphone.core.ChatRoomListenerStub;
import org.linphone.core.ChatRoomParams;
import org.linphone.core.Core; import org.linphone.core.Core;
import org.linphone.core.Factory; import org.linphone.core.Factory;
import org.linphone.core.ProxyConfig; import org.linphone.core.ProxyConfig;
@ -228,13 +229,24 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
&& lpc.getConferenceFactoryUri() != null && lpc.getConferenceFactoryUri() != null
&& !LinphonePreferences.instance().useBasicChatRoomFor1To1()) { && !LinphonePreferences.instance().useBasicChatRoomFor1To1()) {
mWaitLayout.setVisibility(View.VISIBLE); mWaitLayout.setVisibility(View.VISIBLE);
mChatRoom =
lc.createClientGroupChatRoom( ChatRoomParams params = lc.createDefaultChatRoomParams();
getString(R.string.dummy_group_chat_subject), true); params.enableEncryption(false);
mChatRoom.addListener(mChatRoomCreationListener); params.enableGroup(true);
Address participants[] = new Address[1]; Address participants[] = new Address[1];
participants[0] = participant; participants[0] = participant;
mChatRoom.addParticipants(participants);
mChatRoom =
lc.createChatRoom(
params,
getString(R.string.dummy_group_chat_subject),
participants);
if (mChatRoom != null) {
mChatRoom.addListener(mChatRoomCreationListener);
} else {
Log.w("[History Detail Fragment] createChatRoom returned null...");
}
} else { } else {
room = lc.getChatRoom(participant); room = lc.getChatRoom(participant);
LinphoneActivity.instance() LinphoneActivity.instance()