/** * Start this instance by created XMPP account using igven parameters. * * @param serverAddress XMPP server address. * @param xmppDomain XMPP authentication domain. * @param xmppLoginPassword XMPP login(optional). * @param nickName authentication login. * @param listener the listener that will be notified about created protocol provider's * registration state changes. */ public void start( String serverAddress, String xmppDomain, String xmppLoginPassword, String nickName, RegistrationStateChangeListener listener) { this.regListener = listener; xmppProviderFactory = ProtocolProviderFactory.getProtocolProviderFactory( FocusBundleActivator.bundleContext, ProtocolNames.JABBER); if (xmppLoginPassword != null) { xmppAccount = xmppProviderFactory.createAccount( FocusAccountFactory.createFocusAccountProperties( serverAddress, xmppDomain, nickName, xmppLoginPassword)); } else { xmppAccount = xmppProviderFactory.createAccount( FocusAccountFactory.createFocusAccountProperties( serverAddress, xmppDomain, nickName)); } if (!xmppProviderFactory.loadAccount(xmppAccount)) { throw new RuntimeException("Failed to load account: " + xmppAccount); } ServiceReference protoRef = xmppProviderFactory.getProviderForAccount(xmppAccount); protocolService = (ProtocolProviderService) FocusBundleActivator.bundleContext.getService(protoRef); protocolService.addRegistrationStateChangeListener(this); }
/** Stops this instance and removes temporary XMPP account. */ public void stop() { protocolService.removeRegistrationStateChangeListener(this); xmppProviderFactory.uninstallAccount(xmppAccount); }
/** Returns <tt>true</tt> if underlying protocol provider service has registered. */ public boolean isRegistered() { return protocolService.isRegistered(); }
/** {@inheritDoc} */ @Override public String toString() { return protocolService != null ? protocolService.toString() : super.toString(); }
/** Utility method for obtaining operation sets from underlying protocol provider service. */ public <T extends OperationSet> T getOperationSet(Class<T> opSetClass) { return protocolService.getOperationSet(opSetClass); }