1 Reply Latest reply on Jun 19, 2017 8:06 AM by Paul Schaub

    Smack OMEMO Support

    cmeng

      Start implementing OMEMO for aTalk, needs some advice on the following:

       

      During aTalk OMEMO implementation, found that the following method;

      OmemoManager getInstanceFor(XMPPConnection connection);

      has to be called when XMPPConnection is connected i.e. callback connected(XMPPConnection connection) and not when authenticated(XMPPConnection connection, boolean resumed)

       

       

      In the above getInstanceFor() method, it needs to retrieve the BareJid user; However in aTalk implementation, the connection and login occurs in two different processes, and user is not defined during connection process. Moving the execution of the above method when user is authenticated has conflict with OmemoManager#initialize() where it is also being called during authenticated();

       

      Currently to overcome the above limitation, I have to create a private method as below:

      private OmemoManager initOMemoManager(ProtocolProviderService pps) {
         BareJid user;
         XMPPTCPConnection connection = pps.getConnection();

         if (connection.getUser() != null) {
         user = connection.getUser().asBareJid();
         } else {
         user = pps.getAccountID().getFullJid().asBareJid();
         }

         int defaultDeviceId = OmemoService.getInstance().getOmemoStoreBackend().getDefaultDeviceId(user);

         if (defaultDeviceId < 1) {
         defaultDeviceId = OmemoManager.randomDeviceId();
         OmemoService.getInstance().getOmemoStoreBackend().setDefaultDeviceId(user, defaultDeviceId);
         }

         return OmemoManager.getInstanceFor(connection, defaultDeviceId);
      }

       

      Is there other alternative to overcome the problem instead of the above private method approach.

        • Re: Smack OMEMO Support
          Paul Schaub

          Hi cmeng!

          I noticed, that the getInstanceFor(XMPPConnection) method of the OmemoManager is currently broken, which is quite annoying.

          Until its fixed I'd suggest, that your client takes care of generating, storing and providing the deviceId of user accounts, since OmemoManager.getInstanceFor(XMPPConnection, deviceId) should work as intended. Calling getInstanceFor(XMPPConnection) should be avoided for now.

           

          I think your method looks quite good to overcome the issue for now. I'll see if I can push a fix during the week.

           

          I hope this helps you