Smack 4.4.6: How to create omemoStore for use in set OmemoStore Backend(omemoStore)

  • Smack version : 4.4.6
  • The full exception and its stacktrace : None
  • An XMPP trace of the exchanged stream elements between client and server, which can be obtained by setting SmackConfiguration.DEBUG to true : None
  • The relevant code parts (please do not post whole source files!) : See below

Below are the actual aTalk source implementations to perform setOmemoStoreBackend(omemoStore)

OmemoStore is implemented via

SQLiteOmemoStore extends SignalOmemoStore

and setOmemoStoreBackend(omemoStore) are via the following 2 statements i.e.

1. OmemoStore omemoStore = new SQLiteOmemoStore();
2. SignalOmemoService.getInstance().setOmemoStoreBackend(omemoStore);

In Android Studio, both the above statements however are having warnings,

  1. Raw use of parameterized class ‘OmemoStore’
  2. Unchecked assignment: ‘OmemoStore’ to ‘OmemoStore<?,?,?,?,?,?,?,?,?>’

Under Java, the source still compiled and run without problem.

However when the java classes after Kotlin refactored; i.e.

        val omemoStore: OmemoStore<*, *, *, *, *, *, *, *, *> = SQLiteOmemoStore()
        SignalOmemoService.getInstance().setOmemoStoreBackend(omemoStore)

It throws the following errors i.e.:

Type mismatch.
Required: Nothing
Found: OmemoStore<*, *, *, *, *, *, *, *, *>

After looking at the setOmemoStoreBackend(), found it actually redefines it as subclass of OmemoStore.
I am not sure how to resolve this problem. Any help will be much appreciated.

    /**
     * Set an omemoStore as backend. Throws an IllegalStateException, if there is already a backend set.
     *
     * @param omemoStore store.
     */
    @SuppressWarnings("unused")
    public void setOmemoStoreBackend(
            OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore) {
        if (this.omemoStore != null) {
            throw new IllegalStateException("An OmemoStore backend has already been set.");
        }
        this.omemoStore = omemoStore;
    }

// ===== aTalk implementation ==========

public class CryptoActivator implements BundleActivator
{
    .....

    /**
     * Init OMEMO configuration setting and Store
     * - Acknowledge OMEMO licensing.
     * - Initialize the OMEMO configuration settings
     * - Setup OMEMO default data storage
     */
    private void setupOmemoConfigStore()
    {
        SignalOmemoService.acknowledgeLicense();
        SignalOmemoService.setup();

        // Omemo configuration settings
        OmemoConfiguration.setAddOmemoHintBody(true);
        OmemoConfiguration.setRenewOldSignedPreKeys(true);
        OmemoConfiguration.setDeleteStaleDevices(true);

        // Neither of the 2 statements below help to resolve warnings.
        // OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
        //       SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> omemoStore = new SQLiteOmemoStore()
        // OmemoStore<?, ?, ?, ?, ?, ?, ?, ?, ?> omemoStore = new SQLiteOmemoStore();
			
        OmemoStore omemoStore = new SQLiteOmemoStore();
        SignalOmemoService.getInstance().setOmemoStoreBackend(omemoStore);
    }
}

// === aTalk SQLiteOmemoStore class implementation ===

public class SQLiteOmemoStore extends SignalOmemoStore
{
    public SQLiteOmemoStore()
    {
        super();
        mDB = DatabaseBackend.getInstance(aTalkApp.getGlobalContext());
    }
......
}

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.