package de.thedevstack.conversationsplus.xmpp; import java.util.Hashtable; import de.thedevstack.conversationsplus.xmpp.disco.FeatureRegistry; import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacketReceiver; /** */ public class XepRegistry { private final Hashtable xeps = new Hashtable<>(); private static final XepRegistry INSTANCE = new XepRegistry(); public static void enable(String shortName) { if (INSTANCE.xeps.containsKey(shortName)) { Xep xep = INSTANCE.xeps.get(shortName); xep.enable(); FeatureRegistry.remove(xep); IqPacketReceiver.getInstance().registerIqPacketHandler(xep); } } public static void disable(String shortName) { if (INSTANCE.xeps.containsKey(shortName)) { Xep xep = INSTANCE.xeps.get(shortName); xep.disable(); FeatureRegistry.remove(xep); IqPacketReceiver.getInstance().unregisterIqPacketHandler(xep); } } public static void add(Xep xep) { INSTANCE.xeps.put(xep.shortName(), xep); if (xep.isEnabled()) { FeatureRegistry.add(xep); IqPacketReceiver.getInstance().registerIqPacketHandler(xep); } } public static void remove(Xep xep) { INSTANCE.xeps.remove(xep.shortName()); FeatureRegistry.remove(xep); IqPacketReceiver.getInstance().unregisterIqPacketHandler(xep); } public static XepRegistry getInstance() { return INSTANCE; } private XepRegistry() {} }