Class OXInstantMessagingManager

java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.ox_im.OXInstantMessagingManager

public final class OXInstantMessagingManager extends Manager
Entry point of Smacks API for XEP-0374: OpenPGP for XMPP: Instant Messaging.

Setup

In order to set up OX Instant Messaging, please first follow the setup routines of the OpenPgpManager, then do the following steps:

Acquire an OXInstantMessagingManager instance.

 
 OXInstantMessagingManager instantManager = OXInstantMessagingManager.getInstanceFor(connection);
 
 

Listen for OX messages

In order to listen for incoming OX:IM messages, you have to register a listener.
 
 instantManager.addOxMessageListener(
          new OxMessageListener() {
              void newIncomingOxMessage(OpenPgpContact contact,
                                        Message originalMessage,
                                        SigncryptElement decryptedPayload) {
                  Message.Body body = decryptedPayload.<Message.Body>getExtension(Message.Body.ELEMENT, Message.Body.NAMESPACE);
                  ...
              }
          });
 
 

Finally, announce support for OX:IM

In order to let your contacts know, that you support message encrypting using the OpenPGP for XMPP: Instant Messaging profile, you have to announce support for OX:IM.
 
 instantManager.announceSupportForOxInstantMessaging();
 
 

Sending messages

In order to send an OX:IM message, just do
 
 instantManager.sendOxMessage(openPgpManager.getOpenPgpContact(contactsJid), "Hello World");
 
 
Note, that you have to decide, whether to trust the contacts keys prior to sending a message, otherwise undecided keys are not included in the encryption process. You can trust keys by calling OpenPgpContact.trust(OpenPgpV4Fingerprint). Same goes for your own keys! In order to determine, whether there are undecided keys, call OpenPgpContact.hasUndecidedKeys(). The trust state of a single key can be determined using OpenPgpContact.getTrust(OpenPgpV4Fingerprint). Note: This implementation does not yet have support for sending/receiving messages to/from MUCs.
See Also: