congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
MXSession
Code IndexAdd Tabnine to your IDE (free)

How to use
MXSession
in
org.matrix.androidsdk

Best Java code snippets using org.matrix.androidsdk.MXSession (Showing top 20 results out of 315)

origin: matrix-org/matrix-android-sdk

/**
 * Tells if an user is in the ignored user ids list
 *
 * @param userId the user id to test
 * @return true if the user is ignored
 */
public boolean isUserIgnored(String userId) {
  if (null != userId) {
    return getDataHandler().getIgnoredUserIds().indexOf(userId) >= 0;
  }
  return false;
}
origin: matrix-org/matrix-android-sdk

  @Override
  public String toString() {
    return getMyUserId() + " " + super.toString();
  }
}
origin: tijder/SmsMatrix

@Override
public void onStoreReady(String s) {
  session.getDataHandler().checkPermanentStorageData();
  session.startEventStream(store.getEventStreamToken());
  session.getDataHandler().addListener(evLis);
}
origin: matrix-org/matrix-android-sdk

@Override
public void initWithMatrixSession(MXSession matrixSession, String roomId) {
  mSession = matrixSession;
  mCrypto = matrixSession.getCrypto();
  mRoomId = roomId;
  mDeviceId = matrixSession.getCredentials().deviceId;
  // Default rotation periods
  // TODO: Make it configurable via parameters
  mSessionRotationPeriodMsgs = 100;
  mSessionRotationPeriodMs = 7 * 24 * 3600 * 1000;
}
origin: matrix-org/matrix-android-sdk

/**
 * Shorthand for {@link #startEventStream(EventsThreadListener, NetworkConnectivityReceiver, String)} with no eventListener
 * using a DataHandler and no specific failure callback.
 *
 * @param initialToken the initial sync token (null to sync from scratch).
 */
public void startEventStream(String initialToken) {
  checkIfAlive();
  startEventStream(null, mNetworkConnectivityReceiver, initialToken);
}
origin: matrix-org/matrix-android-sdk

/**
 * Constructor
 *
 * @param session                     the session
 * @param networkConnectivityReceiver the network events listener
 */
public BingRulesManager(MXSession session, NetworkConnectivityReceiver networkConnectivityReceiver) {
  mSession = session;
  mApiClient = session.getBingRulesApiClient();
  mMyUserId = session.getCredentials().userId;
  mDataHandler = session.getDataHandler();
  mNetworkListener = new IMXNetworkEventListener() {
    @Override
    public void onNetworkConnectionUpdate(boolean isConnected) {
      // mLoadRulesCallback is set when a loadRules failed
      // so when a network is available, trigger again loadRules
      if (isConnected && (null != mLoadRulesCallback)) {
        loadRules(mLoadRulesCallback);
      }
    }
  };
  mNetworkConnectivityReceiver = networkConnectivityReceiver;
  networkConnectivityReceiver.addEventListener(mNetworkListener);
}
origin: matrix-org/matrix-android-sdk

bobSession.getCredentials().deviceId = "BobDevice";
Assert.assertNull(bobSession.getCrypto());
bobSession.enableCrypto(true, new TestApiCallback<Void>(lock0) {
  @Override
  public void onSuccess(Void info) {
Assert.assertNotNull(bobSession.getCrypto());
final String deviceCurve25519Key = bobSession.getCrypto().getOlmDevice().getDeviceCurve25519Key();
final String deviceEd25519Key = bobSession.getCrypto().getOlmDevice().getDeviceEd25519Key();
final List<MXDeviceInfo> myUserDevices = bobSession.getCrypto().getUserDevices(bobSession.getMyUserId());
bobSession2.getDataHandler().getStore().addMXStoreListener(listener);
bobSession2.getDataHandler().getStore().open();
mTestHelper.await(lock1);
Assert.assertTrue(bobSession2.isCryptoEnabled());
bobSession2.getDataHandler().addListener(eventsListener);
bobSession2.startEventStream(null);
mTestHelper.await(lock2);
Assert.assertTrue(results.containsKey("onInitialSyncComplete"));
Assert.assertTrue(results.containsKey("onCryptoSyncComplete"));
MXCrypto crypto = bobSession2.getCrypto();
origin: matrix-org/matrix-android-sdk

aliceSession.enableCrypto(true, new TestApiCallback<Void>(lock00b) {
  @Override
  public void onSuccess(Void info) {
bobSession.enableCrypto(true, new TestApiCallback<Void>(lock00b) {
  @Override
  public void onSuccess(Void info) {
aliceSession.getCrypto().setWarnOnUnknownDevices(false);
bobSession.getCrypto().setWarnOnUnknownDevices(false);
aliceSession.createRoom(null, null, RoomDirectoryVisibility.DIRECTORY_VISIBILITY_PUBLIC, null, null,
    new TestApiCallback<String>(lock0) {
      @Override
bobSession.joinRoom(aliceRoomId, new TestApiCallback<String>(lock1) {
  @Override
  public void onSuccess(String info) {
Room roomFromAlicePOV = aliceSession.getDataHandler().getRoom(aliceRoomId);
Credentials bobCredentials = bobSession.getCredentials();
bobSession.clear(context);
MXSession bobSession2 = mTestHelper.logIntoAccount(bobSession.getMyUserId(), mCryptoTestHelper.getEncryptedSessionParams());
Assert.assertNotNull(bobSession2);
Assert.assertTrue(bobSession2.isCryptoEnabled());
Assert.assertNotEquals(bobSession2.getCrypto().getMyDevice().deviceId, bobCredentials.deviceId);
bobSession2.getCrypto().setWarnOnUnknownDevices(false);
origin: matrix-org/matrix-android-sdk

final MXSession bobSession = cryptoTestData.getSecondSession();
Credentials bobCredentials = bobSession.getCredentials();
bobSession.clear(context);
bobSession2.getDataHandler().addListener(eventListener);
bobSession2.getDataHandler().getStore().open();
bobSession2.startEventStream(null);
Assert.assertTrue(results.containsKey("onCryptoSyncComplete"));
Assert.assertNotNull(bobSession2.getCrypto());
Room roomFromBobPOV = bobSession2.getDataHandler().getRoom(aliceRoomId);
bobSession2.clear(context);
origin: matrix-org/matrix-android-sdk

MXSession samSession = mTestHelper.createAccount(TestConstants.USER_SAM, createSessionParams);
final String aliceId = aliceSession.getMyUserId();
final String bobId = bobSession.getMyUserId();
final String samId = samSession.getMyUserId();
bobSession.createRoom(new TestApiCallback<String>(latch) {
  @Override
  public void onSuccess(String info) {
final Room bobRoom = bobSession.getDataHandler().getRoom(roomId);
samSession.joinRoom(roomId, new TestApiCallback<String>(latch));
mTestHelper.await(latch);
aliceSession.joinRoom(roomId, new TestApiCallback<String>(latch));
mTestHelper.await(latch);
final Room aliceRoom = aliceSession.getDataHandler().getStore().getRoom(roomId);
aliceSession.clear(context);
bobSession.clear(context);
samSession.clear(context);
origin: matrix-org/matrix-android-sdk

final MXSession bobSession = cryptoTestData.getSecondSession();
bobSession.getCrypto().setWarnOnUnknownDevices(false);
aliceSession.getCrypto().setWarnOnUnknownDevices(false);
final Room roomFromBobPOV = bobSession.getDataHandler().getRoom(aliceRoomId);
final Room roomFromAlicePOV = aliceSession.getDataHandler().getRoom(aliceRoomId);
String bobDeviceId1 = bobSession.getCredentials().deviceId;
bobSession.getDataHandler().addListener(bobEventListener);
String bobId = bobSession.getCredentials().userId;
bobSession.logout(context, new TestApiCallback<Void>(lock2) {
  @Override
  public void onSuccess(Void info) {
aliceSession.getDataHandler().addListener(aliceEventListener);
MXSession bobSession2 = mTestHelper.logIntoAccount(bobSession.getMyUserId(), mCryptoTestHelper.getEncryptedSessionParams());
String bobDeviceId2 = bobSession2.getCredentials().deviceId;
Assert.assertNotEquals(bobDeviceId2, bobDeviceId1);
final Room roomFromBobPOV2 = bobSession2.getDataHandler().getRoom(aliceRoomId);
Assert.assertNotNull(roomFromBobPOV2);
origin: tijder/SmsMatrix

session = new MXSession(hsConfig, dh, context);
session.setSyncDelay(syncDelay * 1000);
session.setSyncTimeout(syncTimeout * 60 * 1000);
Log.e(TAG, "onLogin:" + session.getSyncTimeout());
  session.getDataHandler().checkPermanentStorageData();
  session.startEventStream(store.getEventStreamToken());
  session.getDataHandler().addListener(evLis);
} else {
  store.addMXStoreListener(new IMXStoreListener() {
origin: matrix-org/matrix-android-sdk

bobSession.enableCrypto(true, new TestApiCallback<Void>(lock0) {
  @Override
  public void onSuccess(Void info) {
bobSession.createRoom(new TestApiCallback<String>(lock1) {
  @Override
  public void onSuccess(String info) {
Assert.assertNotNull(roomId[0]);
Room room = bobSession.getDataHandler().getRoom(roomId[0]);
Assert.assertNull(bobSession.getCrypto().getCryptoStore().getRoomAlgorithm(room.getRoomId()));
bobSession.getDataHandler().addListener(new MXEventListener() {
  @Override
  public void onLiveEvent(Event event, RoomState roomState) {
Assert.assertEquals(CryptoConstantsKt.MXCRYPTO_ALGORITHM_MEGOLM, bobSession.getCrypto().getCryptoStore().getRoomAlgorithm(room.getRoomId()));
bobSession.clear(context);
origin: matrix-org/matrix-android-sdk

bobSession.getCrypto().setWarnOnUnknownDevices(false);
aliceSession.getCrypto().setWarnOnUnknownDevices(false);
final Room roomFromBobPOV = bobSession.getDataHandler().getRoom(aliceRoomId);
final Room roomFromAlicePOV = aliceSession.getDataHandler().getRoom(aliceRoomId);
String bobUserId1 = bobSession.getMyUserId();
String aliceUserId1 = aliceSession.getMyUserId();
bobSession.getDataHandler().addListener(bobEventListener);
bobSession.logout(context, new TestApiCallback<Void>(lock2) {
  @Override
  public void onSuccess(Void info) {
aliceSession.logout(context, new TestApiCallback<Void>(lock3) {
  @Override
  public void onSuccess(Void info) {
MXSession bobSession2 = mTestHelper.logIntoAccount(bobSession.getMyUserId(), mCryptoTestHelper.getEncryptedSessionParams());
Assert.assertNotNull(bobSession2);
bobSession2.getCrypto().setWarnOnUnknownDevices(false);
MXSession aliceSession2 = mTestHelper.logIntoAccount(aliceSession.getMyUserId(), mCryptoTestHelper.getEncryptedSessionParams());
Assert.assertNotNull(aliceSession2);
aliceSession2.getCrypto().setWarnOnUnknownDevices(false);
Room roomFromBob2POV = bobSession2.getDataHandler().getRoom(aliceRoomId);
Room roomFromAlice2POV = aliceSession2.getDataHandler().getRoom(aliceRoomId);
origin: matrix-org/matrix-android-sdk

bobSession.getCryptoRestClient().uploadKeys(null, otks, "dev1", new TestApiCallback<KeysUploadResponse>(lock1) {
  @Override
  public void onSuccess(KeysUploadResponse keysUploadResponse) {
usersDevicesKeyTypesMap.setObject("curve25519", bobSession.getMyUserId(), "dev1");
aliceSession.getCryptoRestClient().claimOneTimeKeysForUsersDevices(usersDevicesKeyTypesMap, new TestApiCallback<MXUsersDevicesMap<MXKey>>(lock2) {
  @Override
  public void onSuccess(MXUsersDevicesMap<MXKey> usersDevicesMap) {
Assert.assertEquals(1, oneTimeKeys.getMap().size());
MXKey bobOtk = oneTimeKeys.getObject("dev1", bobSession.getMyUserId());
Assert.assertNotNull(bobOtk);
Assert.assertEquals(1, keys.size());
bobSession.clear(context);
aliceSession.clear(context);
origin: matrix-org/matrix-android-sdk

mRoomDecryptors = new HashMap<>();
String deviceId = mSession.getCredentials().deviceId;
  mSession.getCredentials().deviceId = deviceId = mCryptoStore.getDeviceId();
  mSession.getCredentials().deviceId = deviceId = UUID.randomUUID().toString();
  Log.d(LOG_TAG, "Warning: No device id in MXCredentials. An id was created. Think of storing it");
  mCryptoStore.storeDeviceId(deviceId);
mMyDevice.userId = mSession.getMyUserId();
  keys.put("ed25519:" + mSession.getCredentials().deviceId, mOlmDevice.getDeviceEd25519Key());
  keys.put("curve25519:" + mSession.getCredentials().deviceId, mOlmDevice.getDeviceCurve25519Key());
Map<String, MXDeviceInfo> endToEndDevicesForUser = mCryptoStore.getUserDevices(mSession.getMyUserId());
mCryptoStore.storeUserDevices(mSession.getMyUserId(), myDevices);
mSession.getDataHandler().setCryptoEventsListener(mEventListener);
mEncryptingHandlerThread = new HandlerThread("MXCrypto_encrypting_" + mSession.getMyUserId(), Thread.MIN_PRIORITY);
mEncryptingHandlerThread.start();
mDecryptingHandlerThread = new HandlerThread("MXCrypto_decrypting_" + mSession.getMyUserId(), Thread.MIN_PRIORITY);
mDecryptingHandlerThread.start();
  mDevicesList.handleDeviceListsChanges(Arrays.asList(mSession.getMyUserId()), null);
origin: matrix-org/matrix-android-sdk

final MXSession bobSession = cryptoTestData.getSecondSession();
bobSession.getCrypto().setWarnOnUnknownDevices(false);
aliceSession.getCrypto().setWarnOnUnknownDevices(false);
final Room roomFromBobPOV = bobSession.getDataHandler().getRoom(aliceRoomId);
final Room roomFromAlicePOV = aliceSession.getDataHandler().getRoom(aliceRoomId);
bobSession.getDataHandler().addListener(bobEventListener);
String newSessionKey = aliceSession.getCrypto().getOlmDevice().getSessionKey(sessionId);
bobSession.getDataHandler().onToDeviceEvent(toDeviceEvent);
bobSession.getDataHandler().decryptEvent(event, null);
mCryptoTestHelper.checkEncryptedEvent(event, aliceRoomId, messageFromAlice, aliceSession);
origin: matrix-org/matrix-android-sdk

@Test
public void test01_testCryptoNoDeviceId() throws Exception {
  Log.e(LOG_TAG, "test01_testCryptoNoDeviceId");
  Context context = InstrumentationRegistry.getContext();
  final Map<String, Object> results = new HashMap<>();
  MXSession bobSession = mTestHelper.createAccount(TestConstants.USER_BOB, mCryptoTestHelper.getDefaultSessionParams());
  Assert.assertNull(bobSession.getCrypto());
  bobSession.getCredentials().deviceId = null;
  CountDownLatch lock1 = new CountDownLatch(1);
  bobSession.enableCrypto(true, new TestApiCallback<Void>(lock1) {
    @Override
    public void onSuccess(Void info) {
      results.put("enableCrypto", "enableCrypto");
      super.onSuccess(info);
    }
  });
  mTestHelper.await(lock1);
  Assert.assertTrue(results.containsKey("enableCrypto"));
  Assert.assertNotNull(bobSession.getCrypto());
  Assert.assertNotNull(bobSession.getCredentials().deviceId);
  bobSession.clear(context);
}
origin: matrix-org/matrix-android-sdk

/**
 * Convert a filter to a filterId
 * Either it is already known to the server, or send the filter to the server to get a filterId
 */
private void convertFilterToFilterId() {
  // Ensure mCurrentFilter has not been updated in the same time
  final String wantedJsonFilter = mCurrentFilter.toJSONString();
  // Check if the current filter is known by the server, to directly use the filterId
  String filterId = getDataHandler().getStore().getFilters().get(wantedJsonFilter);
  if (TextUtils.isEmpty(filterId)) {
    // enable the filter in JSON representation so do not block sync until the filter response is there
    mEventsThread.setFilterOrFilterId(wantedJsonFilter);
    // Send the filter to the server
    mFilterRestClient.uploadFilter(getMyUserId(), mCurrentFilter, new SimpleApiCallback<FilterResponse>() {
      @Override
      public void onSuccess(FilterResponse filter) {
        // Store the couple filter/filterId
        getDataHandler().getStore().addFilter(wantedJsonFilter, filter.filterId);
        // Ensure the filter is still corresponding to the current filter
        if (TextUtils.equals(wantedJsonFilter, mCurrentFilter.toJSONString())) {
          // Tell the event thread to use the id now
          mEventsThread.setFilterOrFilterId(filter.filterId);
        }
      }
    });
  } else {
    // Tell the event thread to use the id now
    mEventsThread.setFilterOrFilterId(filterId);
  }
}
origin: matrix-org/matrix-android-sdk

final MXSession bobSession = cryptoTestData.getSecondSession();
bobSession.getCrypto().setWarnOnUnknownDevices(false);
aliceSession.getCrypto().setWarnOnUnknownDevices(false);
final Room roomFromBobPOV = bobSession.getDataHandler().getRoom(aliceRoomId);
final Room roomFromAlicePOV = aliceSession.getDataHandler().getRoom(aliceRoomId);
aliceSession.getCrypto().getDeviceList()
    .downloadKeys(Arrays.asList(bobSession.getMyUserId(), "@pppppppppppp:matrix.org"), false,
        new TestApiCallback<MXUsersDevicesMap<MXDeviceInfo>>(lock1) {
          @Override
Assert.assertEquals(1, usersDevicesInfoMap.getMap().get(bobSession.getMyUserId()).size());
List<String> bobDevices = usersDevicesInfoMap.getUserDeviceIds(bobSession.getMyUserId());
org.matrix.androidsdkMXSession

Javadoc

Class that represents one user's session with a particular home server. There can potentially be multiple sessions for handling multiple accounts.

Most used methods

  • getDataHandler
    Get the data handler.
  • getMyUserId
    Get the session's current userid.
  • startEventStream
    Start the event stream (events thread that listens for events) with an event listener.
  • <init>
  • clear
    Clear the session data. if the callback is null, the clear is synchronous.
  • createRoom
    Create a new room with given properties.
  • enableCrypto
    Enable / disable the crypto.
  • getCredentials
    Get the user credentials.
  • getCrypto
  • getCryptoRestClient
  • getRoomsApiClient
    Get the API client for requests to the rooms API.
  • isCryptoEnabled
  • getRoomsApiClient,
  • isCryptoEnabled,
  • stopEventStream,
  • addDirectChatRoomToAccountData,
  • checkCrypto,
  • checkIfAlive,
  • clearApplicationCaches,
  • convertFilterToFilterId,
  • createDirectMessageRoom,
  • createRoomDirectMessage

Popular in Java

  • Reading from database using SQL prepared statement
  • findViewById (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now