Search in sources :

Example 1 with SignalCachingOmemoStore

use of org.jivesoftware.smackx.omemo.signal.SignalCachingOmemoStore in project Smack by igniterealtime.

the class OmemoClient method main.

public static void main(String[] args) throws XMPPException, SmackException, IOException, InterruptedException, CorruptedOmemoKeyException {
    SmackConfiguration.DEBUG = true;
    if (args.length != 2) {
        print("Missing arguments: <jid> <password>");
        return;
    }
    SignalOmemoService.acknowledgeLicense();
    SignalOmemoService.setup();
    SignalOmemoService omemoService = (SignalOmemoService) SignalOmemoService.getInstance();
    Path omemoStoreDirectory = Files.createTempDirectory("omemo-store");
    omemoService.setOmemoStoreBackend(new SignalCachingOmemoStore(new SignalFileBasedOmemoStore(omemoStoreDirectory.toFile())));
    EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked(args[0]);
    String password = args[1];
    OmemoClient client = new OmemoClient(jid, password);
    try {
        client.start();
        while (true) {
            String input = scanner.nextLine();
            if (input.startsWith("/quit")) {
                break;
            }
            if (input.isEmpty()) {
                continue;
            }
            client.handleInput(input);
        }
    } finally {
        client.stop();
    }
}
Also used : Path(java.nio.file.Path) SignalCachingOmemoStore(org.jivesoftware.smackx.omemo.signal.SignalCachingOmemoStore) SignalFileBasedOmemoStore(org.jivesoftware.smackx.omemo.signal.SignalFileBasedOmemoStore) SignalOmemoService(org.jivesoftware.smackx.omemo.signal.SignalOmemoService) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Aggregations

Path (java.nio.file.Path)1 SignalCachingOmemoStore (org.jivesoftware.smackx.omemo.signal.SignalCachingOmemoStore)1 SignalFileBasedOmemoStore (org.jivesoftware.smackx.omemo.signal.SignalFileBasedOmemoStore)1 SignalOmemoService (org.jivesoftware.smackx.omemo.signal.SignalOmemoService)1 EntityBareJid (org.jxmpp.jid.EntityBareJid)1