/** * Deletes the session agent account, frees all resources and disconnects the XMPP connection. * * @throws org.jivesoftware.smack.XMPPException */ public void shutdown() throws XMPPException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mConnection); // ServiceDiscovery (feature) http://rn.inf.tu-dresden.de/mobilis try { sdm.removeFeature(MobilisManager.discoNamespace); } catch (Exception e) { MobilisManager.getLogger().warning("Problem with ServiceDiscoveryManager: " + e.getMessage()); } // ServiceDiscovery (info+items) http://rn.inf.tu-dresden.de/mobilis#services try { sdm.removeNodeInformationProvider(MobilisManager.discoServicesNode); } catch (Exception e) { MobilisManager.getLogger() .warning( "Problem with NodeInformationProvider: " + MobilisManager.discoServicesNode + " (" + getIdent() + ") " + e.getMessage()); } for (MobilisService service : mServices) { try { sdm.removeNodeInformationProvider(service.getNode()); service.shutdown(); } catch (Exception e) { // TODO Auto-generated catch block } } if ((mConnection != null) && mConnection.isConnected()) { mConnection.removeConnectionListener(this); mConnection.disconnect(); } mConnection = null; // logging MobilisManager.getLogger().info("Mobilis Agent (" + getIdent() + ") shut down."); }
/** * Enable the Jabber services related to file transfer on the particular connection. * * @param connection The connection on which to enable or disable the services. * @param isEnabled True to enable, false to disable. */ public static void setServiceEnabled(final Connection connection, final boolean isEnabled) { final ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(connection); final List<String> namespaces = new ArrayList<String>(); namespaces.addAll(Arrays.asList(NAMESPACE)); namespaces.add(InBandBytestreamManager.NAMESPACE); if (!IBB_ONLY) { namespaces.add(Socks5BytestreamManager.NAMESPACE); } for (final String namespace : namespaces) { if (isEnabled) { if (!manager.includesFeature(namespace)) { manager.addFeature(namespace); } } else { manager.removeFeature(namespace); } } }