Commit 2cc0fb51 authored by Grigory Fedorov's avatar Grigory Fedorov

CarbonManager: code format (indent)

parent 797bf743
package com.xabber.xmpp.carbon;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.SettingsManager;
......@@ -26,22 +15,30 @@ import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.MessageManager;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
/**
* Packet extension for XEP-0280: Message Carbons. This class implements
* the manager for registering {@link Carbon} support, enabling and disabling
* message carbons.
*
* <p/>
* You should call enableCarbons() before sending your first undirected
* presence.
*
* @author Georg Lukas, Semyon Baranov
*/
public class CarbonManager implements OnServerInfoReceivedListener, OnPacketListener
{
private final static CarbonManager instance;
private Connection connection;
private volatile boolean enabled_state = false;
public class CarbonManager implements OnServerInfoReceivedListener, OnPacketListener {
public static final String NAMESPACE = "urn:xmpp:carbons:2";
private final static CarbonManager instance;
static {
instance = new CarbonManager();
......@@ -65,12 +62,25 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
});
}
private Connection connection;
private volatile boolean enabled_state = false;
private CarbonManager() {
}
public static CarbonManager getInstance() {
return instance;
}
private CarbonManager() {
/**
* Mark a message as "private", so it will not be carbon-copied.
*
* @param msg Message object to mark private
*/
public static void disableCarbons(Message msg) {
msg.addExtension(new Private());
}
private IQ carbonsEnabledIQ(final boolean new_state) {
......@@ -118,7 +128,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
/**
* Notify server to change the carbons state. This method returns
* immediately and changes the variable when the reply arrives.
*
* <p/>
* You should first check for support using isSupportedByServer().
*
* @param new_state whether carbons should be enabled or disabled
......@@ -134,7 +144,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
IQ setIQ = carbonsEnabledIQ(new_state);
connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
IQ result = (IQ)packet;
IQ result = (IQ) packet;
if (result.getType() == IQ.Type.RESULT) {
enabled_state = new_state;
}
......@@ -169,16 +179,6 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
return enabled_state;
}
/**
* Mark a message as "private", so it will not be carbon-copied.
*
* @param msg Message object to mark private
*/
public static void disableCarbons(Message msg) {
msg.addExtension(new Private());
}
@Override
public void onPacket(ConnectionItem connection, String bareAddress,
Packet packet) {
......@@ -229,6 +229,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
MessageManager.getInstance().displayForwardedMessage(connection, forwardedMsg, dir);
}
@Override
public void onServerInfoReceived(ConnectionItem connection) {
......@@ -251,6 +252,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
* Marks the message as non-carbon-copied in the following cases:
* - Message Carbons is enabled and OTR mode is enabled.
* - Message Carbons is enabled and OTR security level != plain.
*
* @param abstractChat
* @param message the <tt>Message</tt> to be sent
* @param messageItem
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment