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

ConnectionManager light refactoring.

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