mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Move is(Connected|Authenticated) and getUser()
into AbstractXMPPConnection. Also remove wasAuthenticated field from XMPPBOSHConnection, it is already in AbstractXMPPConnection.
This commit is contained in:
parent
6fec813ec0
commit
5647cac39c
4 changed files with 20 additions and 63 deletions
|
@ -86,10 +86,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
private final BOSHConfiguration config;
|
private final BOSHConfiguration config;
|
||||||
|
|
||||||
// Some flags which provides some info about the current state.
|
// Some flags which provides some info about the current state.
|
||||||
private boolean connected = false;
|
|
||||||
private boolean authenticated = false;
|
|
||||||
private boolean isFirstInitialization = true;
|
private boolean isFirstInitialization = true;
|
||||||
private boolean wasAuthenticated = false;
|
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
|
||||||
// The readerPipe and consumer thread are used for the debugger.
|
// The readerPipe and consumer thread are used for the debugger.
|
||||||
|
@ -217,18 +214,6 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAuthenticated() {
|
|
||||||
return authenticated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConnected() {
|
|
||||||
return connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSecureConnection() {
|
public boolean isSecureConnection() {
|
||||||
// TODO: Implement SSL usage
|
// TODO: Implement SSL usage
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -143,6 +143,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
*/
|
*/
|
||||||
protected String user;
|
protected String user;
|
||||||
|
|
||||||
|
protected boolean connected = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -283,18 +285,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract String getUser();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract String getConnectionID();
|
public abstract String getConnectionID();
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean isConnected();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean isAuthenticated();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean isSecureConnection();
|
public abstract boolean isSecureConnection();
|
||||||
|
|
||||||
|
@ -405,6 +398,22 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
*/
|
*/
|
||||||
public abstract void loginAnonymously() throws XMPPException, SmackException, IOException;
|
public abstract void loginAnonymously() throws XMPPException, SmackException, IOException;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isConnected() {
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isAuthenticated() {
|
||||||
|
return authenticated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
protected void bindResourceAndEstablishSession(String resource) throws XMPPErrorException,
|
protected void bindResourceAndEstablishSession(String resource) throws XMPPErrorException,
|
||||||
IOException, SmackException {
|
IOException, SmackException {
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,9 @@ import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
||||||
*/
|
*/
|
||||||
public class DummyConnection extends AbstractXMPPConnection {
|
public class DummyConnection extends AbstractXMPPConnection {
|
||||||
|
|
||||||
private boolean authenticated = false;
|
|
||||||
private boolean anonymous = false;
|
private boolean anonymous = false;
|
||||||
private boolean reconnect = false;
|
private boolean reconnect = false;
|
||||||
|
|
||||||
private String user;
|
|
||||||
private String connectionID;
|
private String connectionID;
|
||||||
private Roster roster;
|
private Roster roster;
|
||||||
|
|
||||||
|
@ -65,6 +63,8 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
for (ConnectionCreationListener listener : XMPPConnectionRegistry.getConnectionCreationListeners()) {
|
for (ConnectionCreationListener listener : XMPPConnectionRegistry.getConnectionCreationListeners()) {
|
||||||
listener.connectionCreated(this);
|
listener.connectionCreated(this);
|
||||||
}
|
}
|
||||||
|
connected = true;
|
||||||
|
user = "dummy@" + config.getServiceName() + "/Test";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,29 +114,11 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
return roster;
|
return roster;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUser() {
|
|
||||||
if (user == null) {
|
|
||||||
user = "dummy@" + config.getServiceName() + "/Test";
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAnonymous() {
|
public boolean isAnonymous() {
|
||||||
return anonymous;
|
return anonymous;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAuthenticated() {
|
|
||||||
return authenticated;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConnected() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSecureConnection() {
|
public boolean isSecureConnection() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -143,7 +143,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
|
||||||
private String connectionID = null;
|
private String connectionID = null;
|
||||||
private boolean connected = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -342,14 +341,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
return connectionID;
|
return connectionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUser() {
|
|
||||||
if (!isAuthenticated()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install a parsing exception callback, which will be invoked once an exception is encountered while parsing a
|
* Install a parsing exception callback, which will be invoked once an exception is encountered while parsing a
|
||||||
* stanza
|
* stanza
|
||||||
|
@ -478,11 +469,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
afterSuccessfulLogin(true, false);
|
afterSuccessfulLogin(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConnected() {
|
|
||||||
return connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSecureConnection() {
|
public boolean isSecureConnection() {
|
||||||
return usingTLS;
|
return usingTLS;
|
||||||
|
@ -492,11 +478,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
return socketClosed;
|
return socketClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAuthenticated() {
|
|
||||||
return authenticated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts the current connection down. After this method returns, the connection must be ready
|
* Shuts the current connection down. After this method returns, the connection must be ready
|
||||||
* for re-use by connect.
|
* for re-use by connect.
|
||||||
|
|
Loading…
Reference in a new issue