diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java index e63d37452..5e943efc0 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java @@ -1,6 +1,6 @@ /** * - * Copyright 2013-2014 Georg Lukas, 2017-2020 Florian Schmaus, 2020 Paul Schaub + * Copyright 2013-2014 Georg Lukas, 2017-2020 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,6 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.CopyOnWriteArraySet; -import java.util.logging.Level; -import java.util.logging.Logger; import org.jivesoftware.smack.AsyncButOrdered; import org.jivesoftware.smack.ConnectionCreationListener; @@ -73,14 +71,10 @@ import org.jxmpp.jid.EntityFullJid; * * @author Georg Lukas * @author Florian Schmaus - * @author Paul Schaub */ public final class CarbonManager extends Manager { - private static final Logger LOGGER = Logger.getLogger(CarbonManager.class.getName()); - private static Map INSTANCES = new WeakHashMap<>(); - - private static boolean ENABLED_BY_DEFAULT = false; + private static Map INSTANCES = new WeakHashMap(); static { XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() { @@ -105,22 +99,11 @@ public final class CarbonManager extends Manager { private final Set listeners = new CopyOnWriteArraySet<>(); private volatile boolean enabled_state = false; - private volatile boolean enabledByDefault = ENABLED_BY_DEFAULT; private final StanzaListener carbonsListener; private final AsyncButOrdered carbonsListenerAsyncButOrdered = new AsyncButOrdered<>(); - /** - * Should Carbons be automatically be enabled once the connection is authenticated? - * Default: false - * - * @param enabledByDefault new default value - */ - public static void setEnabledByDefault(boolean enabledByDefault) { - ENABLED_BY_DEFAULT = enabledByDefault; - } - private CarbonManager(XMPPConnection connection) { super(connection); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); @@ -128,7 +111,7 @@ public final class CarbonManager extends Manager { carbonsListener = new StanzaListener() { @Override - public void processStanza(final Stanza stanza) { + public void processStanza(final Stanza stanza) throws NotConnectedException, InterruptedException { final Message wrappingMessage = (Message) stanza; final CarbonExtension carbonExtension = CarbonExtension.from(wrappingMessage); final Direction direction = carbonExtension.getDirection(); @@ -162,13 +145,6 @@ public final class CarbonManager extends Manager { if (!resumed) { // Non-resumed XMPP sessions always start with disabled carbons enabled_state = false; - try { - if (shouldCarbonsBeEnabled() && isSupportedByServer()) { - setCarbonsEnabled(true); - } - } catch (InterruptedException | XMPPErrorException | NotConnectedException | NoResponseException e) { - LOGGER.log(Level.WARNING, "Cannot check for Carbon support and / or enable carbons.", e); - } } addCarbonsListener(connection); } @@ -263,10 +239,12 @@ public final class CarbonManager extends Manager { * You should first check for support using isSupportedByServer(). * * @param new_state whether carbons should be enabled or disabled + * @throws NotConnectedException if the XMPP connection is not connected. + * @throws InterruptedException if the calling thread was interrupted. * @deprecated use {@link #enableCarbonsAsync(ExceptionCallback)} or {@link #disableCarbonsAsync(ExceptionCallback)} instead. */ @Deprecated - public void sendCarbonsEnabled(final boolean new_state) { + public void sendCarbonsEnabled(final boolean new_state) throws NotConnectedException, InterruptedException { sendUseCarbons(new_state, null); } @@ -303,7 +281,6 @@ public final class CarbonManager extends Manager { } private void sendUseCarbons(final boolean use, ExceptionCallback exceptionCallback) { - enabledByDefault = use; IQ setIQ = carbonsEnabledIQ(use); SmackFuture future = connection().sendIqRequestAsync(setIQ); @@ -333,7 +310,6 @@ public final class CarbonManager extends Manager { */ public synchronized void setCarbonsEnabled(final boolean new_state) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { - enabledByDefault = new_state; if (enabled_state == new_state) return; @@ -374,10 +350,6 @@ public final class CarbonManager extends Manager { return this.enabled_state; } - private boolean shouldCarbonsBeEnabled() { - return enabledByDefault; - } - /** * Mark a message as "private", so it will not be carbon-copied. * diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableConfigureForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableConfigureForm.java index 6f2b9f5f3..0d7ebd039 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableConfigureForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableConfigureForm.java @@ -36,7 +36,7 @@ import org.jxmpp.jid.Jid; public class FillableConfigureForm extends FillableForm implements ConfigureFormReader { - FillableConfigureForm(DataForm dataForm) { + public FillableConfigureForm(DataForm dataForm) { super(dataForm); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableSubscribeForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableSubscribeForm.java index 2b5206d06..396678097 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableSubscribeForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/FillableSubscribeForm.java @@ -26,9 +26,9 @@ import org.jivesoftware.smackx.xdata.ListMultiFormField; import org.jivesoftware.smackx.xdata.form.FillableForm; import org.jivesoftware.smackx.xdata.packet.DataForm; -public class FillableSubscribeForm extends FillableForm implements SubscribeFormReader { +public class FillableSubscribeForm extends FillableForm { - FillableSubscribeForm(DataForm dataForm) { + public FillableSubscribeForm(DataForm dataForm) { super(dataForm); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/SubscribeForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/SubscribeForm.java index 568871a07..b1e173d5d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/SubscribeForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/form/SubscribeForm.java @@ -26,8 +26,4 @@ public class SubscribeForm extends Form implements SubscribeFormReader { ensureFormType(dataForm, FORM_TYPE); } - @Override - public FillableSubscribeForm getFillableForm() { - return new FillableSubscribeForm(getDataForm()); - } }