use of org.matrix.androidsdk.rest.model.CreateRoomParams in project matrix-android-sdk by matrix-org.
the class MXSession method createDirectMessageRoom.
/**
* Create a direct message room with one participant.<br>
* The participant can be a user ID or mail address. Once the room is created, on success, the room
* is set as a "direct message" with the participant.
*
* @param aParticipantUserId user ID (or user mail) to be invited in the direct message room
* @param algorithm the crypto algorithm (null to create an unencrypted room)
* @param aCreateRoomCallBack async call back response
* @return true if the invite was performed, false otherwise
*/
public boolean createDirectMessageRoom(final String aParticipantUserId, final String algorithm, final ApiCallback<String> aCreateRoomCallBack) {
boolean retCode = false;
if (!TextUtils.isEmpty(aParticipantUserId)) {
retCode = true;
CreateRoomParams params = new CreateRoomParams();
params.addCryptoAlgorithm(algorithm);
params.setDirectMessage();
params.addParticipantIds(mHsConfig, Arrays.asList(aParticipantUserId));
createRoom(params, aCreateRoomCallBack);
}
return retCode;
}
use of org.matrix.androidsdk.rest.model.CreateRoomParams in project matrix-android-sdk by matrix-org.
the class MXSession method createRoom.
/**
* Create a new room with given properties. Needs the data handler.
*
* @param name the room name
* @param topic the room topic
* @param visibility the room visibility
* @param alias the room alias
* @param guestAccess the guest access rule (see {@link RoomState#GUEST_ACCESS_CAN_JOIN} or {@link RoomState#GUEST_ACCESS_FORBIDDEN})
* @param historyVisibility the history visibility
* @param algorithm the crypto algorithm (null to create an unencrypted room)
* @param callback the async callback once the room is ready
*/
public void createRoom(String name, String topic, String visibility, String alias, String guestAccess, String historyVisibility, String algorithm, final ApiCallback<String> callback) {
checkIfAlive();
CreateRoomParams params = new CreateRoomParams();
params.name = !TextUtils.isEmpty(name) ? name : null;
params.topic = !TextUtils.isEmpty(topic) ? topic : null;
params.visibility = !TextUtils.isEmpty(visibility) ? visibility : null;
params.roomAliasName = !TextUtils.isEmpty(alias) ? alias : null;
params.guest_access = !TextUtils.isEmpty(guestAccess) ? guestAccess : null;
params.history_visibility = !TextUtils.isEmpty(historyVisibility) ? historyVisibility : null;
params.addCryptoAlgorithm(algorithm);
createRoom(params, callback);
}
use of org.matrix.androidsdk.rest.model.CreateRoomParams in project matrix-android-sdk by matrix-org.
the class MXSession method createEncryptedRoom.
/**
* Create an encrypted room.
*
* @param algorithm the encryption algorithm.
* @param callback the async callback once the room is ready
*/
public void createEncryptedRoom(String algorithm, final ApiCallback<String> callback) {
CreateRoomParams params = new CreateRoomParams();
params.addCryptoAlgorithm(algorithm);
createRoom(params, callback);
}
use of org.matrix.androidsdk.rest.model.CreateRoomParams in project matrix-android-sdk by matrix-org.
the class MXCallsManager method getConferenceUserRoom.
/**
* Get the room with the conference user dedicated for the passed room.
*
* @param roomId the room id.
* @param callback the async callback.
*/
private void getConferenceUserRoom(final String roomId, final ApiCallback<Room> callback) {
Log.d(LOG_TAG, "getConferenceUserRoom with room id " + roomId);
String conferenceUserId = getConferenceUserId(roomId);
Room conferenceRoom = null;
Collection<Room> rooms = mSession.getDataHandler().getStore().getRooms();
// Use an existing 1:1 with the conference user; else make one
for (Room room : rooms) {
if (room.isConferenceUserRoom() && (2 == room.getMembers().size()) && (null != room.getMember(conferenceUserId))) {
conferenceRoom = room;
break;
}
}
if (null != conferenceRoom) {
Log.d(LOG_TAG, "getConferenceUserRoom : the room already exists");
final Room fConferenceRoom = conferenceRoom;
mSession.getDataHandler().getStore().commit();
mUIThreadHandler.post(new Runnable() {
@Override
public void run() {
callback.onSuccess(fConferenceRoom);
}
});
} else {
Log.d(LOG_TAG, "getConferenceUserRoom : create the room");
CreateRoomParams params = new CreateRoomParams();
params.preset = CreateRoomParams.PRESET_PRIVATE_CHAT;
params.invite = Arrays.asList(conferenceUserId);
mSession.createRoom(params, new ApiCallback<String>() {
@Override
public void onSuccess(String roomId) {
Log.d(LOG_TAG, "getConferenceUserRoom : the room creation succeeds");
Room room = mSession.getDataHandler().getRoom(roomId);
if (null != room) {
room.setIsConferenceUserRoom(true);
mSession.getDataHandler().getStore().commit();
callback.onSuccess(room);
}
}
@Override
public void onNetworkError(Exception e) {
Log.d(LOG_TAG, "getConferenceUserRoom : failed " + e.getMessage());
callback.onNetworkError(e);
}
@Override
public void onMatrixError(MatrixError e) {
Log.d(LOG_TAG, "getConferenceUserRoom : failed " + e.getMessage());
callback.onMatrixError(e);
}
@Override
public void onUnexpectedError(Exception e) {
Log.d(LOG_TAG, "getConferenceUserRoom : failed " + e.getMessage());
callback.onUnexpectedError(e);
}
});
}
}
Aggregations