mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
SMACK-279: The XMPPConnection extends the new abstract Connection class
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11613 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
11a41e79ca
commit
127319a821
102 changed files with 1420 additions and 1194 deletions
|
@ -40,7 +40,7 @@ import org.jivesoftware.smack.PacketCollector;
|
|||
import org.jivesoftware.smack.PacketInterceptor;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||
|
@ -79,10 +79,10 @@ public class MultiUserChat {
|
|||
private final static String discoNamespace = "http://jabber.org/protocol/muc";
|
||||
private final static String discoNode = "http://jabber.org/protocol/muc#rooms";
|
||||
|
||||
private static Map<XMPPConnection, List<String>> joinedRooms =
|
||||
new WeakHashMap<XMPPConnection, List<String>>();
|
||||
private static Map<Connection, List<String>> joinedRooms =
|
||||
new WeakHashMap<Connection, List<String>>();
|
||||
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
private String room;
|
||||
private String subject;
|
||||
private String nickname = null;
|
||||
|
@ -106,8 +106,8 @@ public class MultiUserChat {
|
|||
private List<PacketListener> connectionListeners = new ArrayList<PacketListener>();
|
||||
|
||||
static {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(final XMPPConnection connection) {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(final Connection connection) {
|
||||
// Set on every established connection that this client supports the Multi-User
|
||||
// Chat protocol. This information will be used when another client tries to
|
||||
// discover whether this client supports MUC or not.
|
||||
|
@ -153,7 +153,7 @@ public class MultiUserChat {
|
|||
* "service" is the hostname at which the multi-user chat
|
||||
* service is running. Make sure to provide a valid JID.
|
||||
*/
|
||||
public MultiUserChat(XMPPConnection connection, String room) {
|
||||
public MultiUserChat(Connection connection, String room) {
|
||||
this.connection = connection;
|
||||
this.room = room.toLowerCase();
|
||||
init();
|
||||
|
@ -166,7 +166,7 @@ public class MultiUserChat {
|
|||
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
||||
* @return a boolean indicating whether the specified user supports the MUC protocol.
|
||||
*/
|
||||
public static boolean isServiceEnabled(XMPPConnection connection, String user) {
|
||||
public static boolean isServiceEnabled(Connection connection, String user) {
|
||||
try {
|
||||
DiscoverInfo result =
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(user);
|
||||
|
@ -186,7 +186,7 @@ public class MultiUserChat {
|
|||
* @param connection the connection used to join the rooms.
|
||||
* @return an Iterator on the rooms where the user has joined using a given connection.
|
||||
*/
|
||||
private static Iterator<String> getJoinedRooms(XMPPConnection connection) {
|
||||
private static Iterator<String> getJoinedRooms(Connection connection) {
|
||||
List<String> rooms = joinedRooms.get(connection);
|
||||
if (rooms != null) {
|
||||
return rooms.iterator();
|
||||
|
@ -203,7 +203,7 @@ public class MultiUserChat {
|
|||
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
||||
* @return an Iterator on the rooms where the requested user has joined.
|
||||
*/
|
||||
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user) {
|
||||
public static Iterator<String> getJoinedRooms(Connection connection, String user) {
|
||||
try {
|
||||
ArrayList<String> answer = new ArrayList<String>();
|
||||
// Send the disco packet to the user
|
||||
|
@ -232,7 +232,7 @@ public class MultiUserChat {
|
|||
* @return the discovered information of a given room without actually having to join the room.
|
||||
* @throws XMPPException if an error occured while trying to discover information of a room.
|
||||
*/
|
||||
public static RoomInfo getRoomInfo(XMPPConnection connection, String room)
|
||||
public static RoomInfo getRoomInfo(Connection connection, String room)
|
||||
throws XMPPException {
|
||||
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
|
||||
return new RoomInfo(info);
|
||||
|
@ -245,7 +245,7 @@ public class MultiUserChat {
|
|||
* @return a collection with the XMPP addresses of the Multi-User Chat services.
|
||||
* @throws XMPPException if an error occured while trying to discover MUC services.
|
||||
*/
|
||||
public static Collection<String> getServiceNames(XMPPConnection connection) throws XMPPException {
|
||||
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
|
||||
final List<String> answer = new ArrayList<String>();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
||||
|
@ -275,7 +275,7 @@ public class MultiUserChat {
|
|||
* @return a collection of HostedRooms.
|
||||
* @throws XMPPException if an error occured while trying to discover the information.
|
||||
*/
|
||||
public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection, String serviceName)
|
||||
public static Collection<HostedRoom> getHostedRooms(Connection connection, String serviceName)
|
||||
throws XMPPException {
|
||||
List<HostedRoom> answer = new ArrayList<HostedRoom>();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
@ -768,7 +768,7 @@ public class MultiUserChat {
|
|||
* @param inviter the inviter of the declined invitation.
|
||||
* @param reason the reason why the invitee is declining the invitation.
|
||||
*/
|
||||
public static void decline(XMPPConnection conn, String room, String inviter, String reason) {
|
||||
public static void decline(Connection conn, String room, String inviter, String reason) {
|
||||
Message message = new Message(room);
|
||||
|
||||
// Create the MUCUser packet that will include the rejection
|
||||
|
@ -790,7 +790,7 @@ public class MultiUserChat {
|
|||
* @param conn the connection where the listener will be applied.
|
||||
* @param listener an invitation listener.
|
||||
*/
|
||||
public static void addInvitationListener(XMPPConnection conn, InvitationListener listener) {
|
||||
public static void addInvitationListener(Connection conn, InvitationListener listener) {
|
||||
InvitationsMonitor.getInvitationsMonitor(conn).addInvitationListener(listener);
|
||||
}
|
||||
|
||||
|
@ -801,7 +801,7 @@ public class MultiUserChat {
|
|||
* @param conn the connection where the listener was applied.
|
||||
* @param listener an invitation listener.
|
||||
*/
|
||||
public static void removeInvitationListener(XMPPConnection conn, InvitationListener listener) {
|
||||
public static void removeInvitationListener(Connection conn, InvitationListener listener) {
|
||||
InvitationsMonitor.getInvitationsMonitor(conn).removeInvitationListener(listener);
|
||||
}
|
||||
|
||||
|
@ -1901,7 +1901,7 @@ public class MultiUserChat {
|
|||
* group chat. Only "group chat" messages addressed to this group chat will
|
||||
* be delivered to the listener. If you wish to listen for other packets
|
||||
* that may be associated with this group chat, you should register a
|
||||
* PacketListener directly with the XMPPConnection with the appropriate
|
||||
* PacketListener directly with the Connection with the appropriate
|
||||
* PacketListener.
|
||||
*
|
||||
* @param listener a packet listener.
|
||||
|
@ -2555,12 +2555,12 @@ public class MultiUserChat {
|
|||
private static class InvitationsMonitor implements ConnectionListener {
|
||||
// We use a WeakHashMap so that the GC can collect the monitor when the
|
||||
// connection is no longer referenced by any object.
|
||||
private final static Map<XMPPConnection, WeakReference<InvitationsMonitor>> monitors =
|
||||
new WeakHashMap<XMPPConnection, WeakReference<InvitationsMonitor>>();
|
||||
private final static Map<Connection, WeakReference<InvitationsMonitor>> monitors =
|
||||
new WeakHashMap<Connection, WeakReference<InvitationsMonitor>>();
|
||||
|
||||
private final List<InvitationListener> invitationsListeners =
|
||||
new ArrayList<InvitationListener>();
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
private PacketFilter invitationFilter;
|
||||
private PacketListener invitationPacketListener;
|
||||
|
||||
|
@ -2570,7 +2570,7 @@ public class MultiUserChat {
|
|||
* @param conn the connection to monitor for room invitations.
|
||||
* @return a new or existing InvitationsMonitor for a given connection.
|
||||
*/
|
||||
public static InvitationsMonitor getInvitationsMonitor(XMPPConnection conn) {
|
||||
public static InvitationsMonitor getInvitationsMonitor(Connection conn) {
|
||||
synchronized (monitors) {
|
||||
if (!monitors.containsKey(conn)) {
|
||||
// We need to use a WeakReference because the monitor references the
|
||||
|
@ -2589,7 +2589,7 @@ public class MultiUserChat {
|
|||
*
|
||||
* @param connection the connection to monitor for possible room invitations
|
||||
*/
|
||||
private InvitationsMonitor(XMPPConnection connection) {
|
||||
private InvitationsMonitor(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue