Commit 4a1fae99 authored by Grigory Fedorov's avatar Grigory Fedorov

ConnectionManager light refactoring.

parent 687c63ae
...@@ -337,7 +337,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -337,7 +337,7 @@ public class MessageArchiveManager implements OnPacketListener,
auto.setSave(true); auto.setSave(true);
auto.setType(Type.set); auto.setType(Type.set);
try { try {
ConnectionManager.getInstance().sendPacket(account, auto); ConnectionManager.getInstance().sendStanza(account, auto);
} catch (NetworkException e) { } catch (NetworkException e) {
} }
// TODO: track results. // TODO: track results.
...@@ -394,7 +394,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -394,7 +394,7 @@ public class MessageArchiveManager implements OnPacketListener,
pref.setDefault(defaultItem); pref.setDefault(defaultItem);
pref.setType(Type.set); pref.setType(Type.set);
try { try {
ConnectionManager.getInstance().sendPacket(account, pref); ConnectionManager.getInstance().sendStanza(account, pref);
} catch (NetworkException e) { } catch (NetworkException e) {
} }
} }
...@@ -703,7 +703,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -703,7 +703,7 @@ public class MessageArchiveManager implements OnPacketListener,
packet.setEnd(connected.get(account)); packet.setEnd(connected.get(account));
String packetId = packet.getPacketID(); String packetId = packet.getPacketID();
try { try {
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} catch (NetworkException e) { } catch (NetworkException e) {
} }
return packetId; return packetId;
...@@ -722,7 +722,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -722,7 +722,7 @@ public class MessageArchiveManager implements OnPacketListener,
modificationRequests.put(account, packet.getPacketID(), modification); modificationRequests.put(account, packet.getPacketID(), modification);
try { try {
if (!modification) { if (!modification) {
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
return; return;
} }
ConnectionManager.getInstance().sendRequest(account, packet, ConnectionManager.getInstance().sendRequest(account, packet,
...@@ -766,7 +766,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -766,7 +766,7 @@ public class MessageArchiveManager implements OnPacketListener,
Pref packet = new Pref(); Pref packet = new Pref();
packet.addItem(extension); packet.addItem(extension);
packet.setType(Type.set); packet.setType(Type.set);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
private void sendItemRemove(String account, String user) private void sendItemRemove(String account, String user)
...@@ -776,7 +776,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -776,7 +776,7 @@ public class MessageArchiveManager implements OnPacketListener,
ItemRemove packet = new ItemRemove(); ItemRemove packet = new ItemRemove();
packet.addItem(extension); packet.addItem(extension);
packet.setType(Type.set); packet.setType(Type.set);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
public void setOtrMode(String account, String user, OtrMode otrMode) public void setOtrMode(String account, String user, OtrMode otrMode)
...@@ -862,7 +862,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -862,7 +862,7 @@ public class MessageArchiveManager implements OnPacketListener,
Pref packet = new Pref(); Pref packet = new Pref();
packet.addSession(extension); packet.addSession(extension);
packet.setType(Type.set); packet.setType(Type.set);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
sessionSaves.put(account, session, saveMode); sessionSaves.put(account, session, saveMode);
} }
...@@ -873,7 +873,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -873,7 +873,7 @@ public class MessageArchiveManager implements OnPacketListener,
SessionRemove packet = new SessionRemove(); SessionRemove packet = new SessionRemove();
packet.addSession(extension); packet.addSession(extension);
packet.setType(Type.set); packet.setType(Type.set);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
sessionSaves.remove(account, session); sessionSaves.remove(account, session);
} }
......
...@@ -194,7 +194,7 @@ public class AttentionManager implements OnPacketListener, OnLoadListener { ...@@ -194,7 +194,7 @@ public class AttentionManager implements OnPacketListener, OnLoadListener {
message.setTo(to); message.setTo(to);
message.setType(Message.Type.headline); message.setType(Message.Type.headline);
message.addExtension(new Attention()); message.addExtension(new Attention());
ConnectionManager.getInstance().sendPacket(account, message); ConnectionManager.getInstance().sendStanza(account, message);
chat.newAction(null, null, ChatAction.attention_called); chat.newAction(null, null, ChatAction.attention_called);
} }
......
...@@ -218,7 +218,7 @@ public class CapabilitiesManager implements OnAuthorizedListener, ...@@ -218,7 +218,7 @@ public class CapabilitiesManager implements OnAuthorizedListener,
if (capability.getNode() != null && capability.getVersion() != null) if (capability.getNode() != null && capability.getVersion() != null)
packet.setNode(capability.getNode() + "#" + capability.getVersion()); packet.setNode(capability.getNode() + "#" + capability.getVersion());
try { try {
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} catch (NetworkException e) { } catch (NetworkException e) {
return; return;
} }
......
...@@ -215,7 +215,7 @@ public class ChatStateManager implements OnDisconnectListener, ...@@ -215,7 +215,7 @@ public class ChatStateManager implements OnDisconnectListener,
message.setTo(chat.getTo()); message.setTo(chat.getTo());
message.addExtension(new ChatStateExtension(chatState)); message.addExtension(new ChatStateExtension(chatState));
try { try {
ConnectionManager.getInstance().sendPacket(account, message); ConnectionManager.getInstance().sendStanza(account, message);
} catch (NetworkException e) { } catch (NetworkException e) {
// Just ignore it. // Just ignore it.
} }
......
...@@ -39,7 +39,6 @@ import org.jivesoftware.smack.SmackException; ...@@ -39,7 +39,6 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.muc.MultiUserChat; import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.MultiUserChatManager; import org.jivesoftware.smackx.muc.MultiUserChatManager;
...@@ -442,7 +441,7 @@ public class MUCManager implements OnLoadListener, OnPacketListener { ...@@ -442,7 +441,7 @@ public class MUCManager implements OnLoadListener, OnPacketListener {
invite.setReason(""); invite.setReason("");
mucUser.setInvite(invite); mucUser.setInvite(invite);
message.addExtension(mucUser); message.addExtension(mucUser);
ConnectionManager.getInstance().sendPacket(account, message); ConnectionManager.getInstance().sendStanza(account, message);
roomChat.putInvite(message.getPacketID(), user); roomChat.putInvite(message.getPacketID(), user);
roomChat.newAction(roomChat.getNickname(), user, ChatAction.invite_sent); roomChat.newAction(roomChat.getNickname(), user, ChatAction.invite_sent);
} }
......
...@@ -235,7 +235,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -235,7 +235,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
SSNManager.getInstance().setSessionOtrMode(account, user, abstractChat.getThreadId(), OtrMode.prefer); SSNManager.getInstance().setSessionOtrMode(account, user, abstractChat.getThreadId(), OtrMode.prefer);
try { try {
ConnectionManager.getInstance() ConnectionManager.getInstance()
.sendPacket(abstractChat.getAccount(), abstractChat.createMessagePacket(msg)); .sendStanza(abstractChat.getAccount(), abstractChat.createMessagePacket(msg));
} catch (NetworkException e) { } catch (NetworkException e) {
throw new OtrException(e); throw new OtrException(e);
} }
......
...@@ -69,7 +69,7 @@ public class PingManager implements OnPacketListener { ...@@ -69,7 +69,7 @@ public class PingManager implements OnPacketListener {
if (ping.getType() != IQ.Type.get) if (ping.getType() != IQ.Type.get)
return; return;
try { try {
ConnectionManager.getInstance().sendPacket(account, ConnectionManager.getInstance().sendStanza(account,
IQ.createResultIQ(ping)); IQ.createResultIQ(ping));
} catch (NetworkException e) { } catch (NetworkException e) {
LogManager.exception(this, e); LogManager.exception(this, e);
......
...@@ -292,7 +292,7 @@ public class SSNManager implements OnPacketListener, OnAccountRemovedListener { ...@@ -292,7 +292,7 @@ public class SSNManager implements OnPacketListener, OnAccountRemovedListener {
message.setThread(session); message.setThread(session);
message.addExtension(feature); message.addExtension(feature);
try { try {
ConnectionManager.getInstance().sendPacket(account, message); ConnectionManager.getInstance().sendStanza(account, message);
} catch (NetworkException e) { } catch (NetworkException e) {
} }
} }
......
...@@ -127,7 +127,7 @@ public class TimeManager implements OnServerInfoReceivedListener, ...@@ -127,7 +127,7 @@ public class TimeManager implements OnServerInfoReceivedListener,
.get(Calendar.DST_OFFSET)) / 60000); .get(Calendar.DST_OFFSET)) / 60000);
result.setUtc(calendar.getTime()); result.setUtc(calendar.getTime());
try { try {
ConnectionManager.getInstance().sendPacket(account, result); ConnectionManager.getInstance().sendStanza(account, result);
} catch (NetworkException e) { } catch (NetworkException e) {
} }
} }
......
...@@ -24,7 +24,6 @@ import java.util.Set; ...@@ -24,7 +24,6 @@ import java.util.Set;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
...@@ -195,7 +194,7 @@ public class VCardManager implements OnLoadListener, OnPacketListener, ...@@ -195,7 +194,7 @@ public class VCardManager implements OnLoadListener, OnPacketListener,
if (hash != null) if (hash != null)
request.addHash(hash); request.addHash(hash);
try { try {
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} catch (NetworkException e) { } catch (NetworkException e) {
requests.remove(request); requests.remove(request);
onVCardFailed(account, bareAddress); onVCardFailed(account, bareAddress);
......
...@@ -34,7 +34,6 @@ import com.xabber.xmpp.carbon.CarbonManager; ...@@ -34,7 +34,6 @@ import com.xabber.xmpp.carbon.CarbonManager;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type; import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.delay.packet.DelayInformation; import org.jivesoftware.smackx.delay.packet.DelayInformation;
...@@ -583,7 +582,7 @@ public abstract class AbstractChat extends BaseEntity { ...@@ -583,7 +582,7 @@ public abstract class AbstractChat extends BaseEntity {
.getTimestamp())); .getTimestamp()));
try { try {
ConnectionManager.getInstance() ConnectionManager.getInstance()
.sendPacket(account, message); .sendStanza(account, message);
} catch (NetworkException e) { } catch (NetworkException e) {
break; break;
} }
......
...@@ -137,7 +137,7 @@ public class ReceiptManager implements OnPacketListener, OnDisconnectListener { ...@@ -137,7 +137,7 @@ public class ReceiptManager implements OnPacketListener, OnDisconnectListener {
receipt.addExtension(new Received(id)); receipt.addExtension(new Received(id));
receipt.setThread(message.getThread()); receipt.setThread(message.getThread());
try { try {
ConnectionManager.getInstance().sendPacket(account, ConnectionManager.getInstance().sendStanza(account,
receipt); receipt);
} catch (NetworkException e) { } catch (NetworkException e) {
LogManager.exception(this, e); LogManager.exception(this, e);
......
...@@ -124,7 +124,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener, ...@@ -124,7 +124,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
throws NetworkException { throws NetworkException {
Presence packet = new Presence(Presence.Type.subscribe); Presence packet = new Presence(Presence.Type.subscribe);
packet.setTo(bareAddress); packet.setTo(bareAddress);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
HashSet<String> set = requestedSubscriptions.get(account); HashSet<String> set = requestedSubscriptions.get(account);
if (set == null) { if (set == null) {
set = new HashSet<String>(); set = new HashSet<String>();
...@@ -150,7 +150,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener, ...@@ -150,7 +150,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
throws NetworkException { throws NetworkException {
Presence packet = new Presence(Presence.Type.subscribed); Presence packet = new Presence(Presence.Type.subscribed);
packet.setTo(bareAddress); packet.setTo(bareAddress);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
subscriptionRequestProvider.remove(account, bareAddress); subscriptionRequestProvider.remove(account, bareAddress);
removeRequestedSubscription(account, bareAddress); removeRequestedSubscription(account, bareAddress);
} }
...@@ -167,7 +167,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener, ...@@ -167,7 +167,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
throws NetworkException { throws NetworkException {
Presence packet = new Presence(Presence.Type.unsubscribed); Presence packet = new Presence(Presence.Type.unsubscribed);
packet.setTo(bareAddress); packet.setTo(bareAddress);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
subscriptionRequestProvider.remove(account, bareAddress); subscriptionRequestProvider.remove(account, bareAddress);
removeRequestedSubscription(account, bareAddress); removeRequestedSubscription(account, bareAddress);
} }
...@@ -381,7 +381,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener, ...@@ -381,7 +381,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
public void resendPresence(String account) throws NetworkException { public void resendPresence(String account) throws NetworkException {
if (!readyAccounts.contains(account)) if (!readyAccounts.contains(account))
throw new NetworkException(R.string.NOT_CONNECTED); throw new NetworkException(R.string.NOT_CONNECTED);
ConnectionManager.getInstance().sendPacket(account, ConnectionManager.getInstance().sendStanza(account,
AccountManager.getInstance().getAccount(account).getPresence()); AccountManager.getInstance().getAccount(account).getPresence());
} }
......
...@@ -302,7 +302,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener, ...@@ -302,7 +302,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
if (group.trim().length() > 0) if (group.trim().length() > 0)
item.addGroupName(group); item.addGroupName(group);
packet.addRosterItem(item); packet.addRosterItem(item);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
/** /**
...@@ -319,7 +319,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener, ...@@ -319,7 +319,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
RosterPacket.Item item = new RosterPacket.Item(bareAddress, ""); RosterPacket.Item item = new RosterPacket.Item(bareAddress, "");
item.setItemType(RosterPacket.ItemType.remove); item.setItemType(RosterPacket.ItemType.remove);
packet.addRosterItem(item); packet.addRosterItem(item);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
public void setGroups(String account, String bareAddress, Collection<String> groups) throws NetworkException { public void setGroups(String account, String bareAddress, Collection<String> groups) throws NetworkException {
...@@ -357,7 +357,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener, ...@@ -357,7 +357,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
item.addGroupName(group); item.addGroupName(group);
} }
packet.addRosterItem(item); packet.addRosterItem(item);
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
/** /**
...@@ -384,7 +384,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener, ...@@ -384,7 +384,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
} }
if (packet.getRosterItemCount() == 0) if (packet.getRosterItemCount() == 0)
return; return;
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
/** /**
...@@ -439,7 +439,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener, ...@@ -439,7 +439,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
} }
if (packet.getRosterItemCount() == 0) if (packet.getRosterItemCount() == 0)
return; return;
ConnectionManager.getInstance().sendPacket(account, packet); ConnectionManager.getInstance().sendStanza(account, packet);
} }
/** /**
...@@ -500,7 +500,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener, ...@@ -500,7 +500,7 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
String account = ((AccountItem) connection).getAccount(); String account = ((AccountItem) connection).getAccount();
requestedRosters.add(account); requestedRosters.add(account);
try { try {
ConnectionManager.getInstance().sendPacket(account, ConnectionManager.getInstance().sendStanza(account,
new RosterPacket()); new RosterPacket());
} catch (NetworkException e) { } catch (NetworkException e) {
LogManager.exception(this, e); LogManager.exception(this, e);
......
...@@ -149,7 +149,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList ...@@ -149,7 +149,7 @@ public class CarbonManager implements OnServerInfoReceivedListener, OnPacketList
// } // }
// }, new StanzaIdFilter(setIQ.getStanzaId())); // }, new StanzaIdFilter(setIQ.getStanzaId()));
// //
// connection.sendPacket(setIQ); // connection.sendStanza(setIQ);
} }
/** /**
......
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