feat(core): Remove getter and setter for connectionSettings
This commit is contained in:
parent
47d821c02e
commit
3e43ac22d7
@ -108,12 +108,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
connection.setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
connection.connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString(jidController.text),
|
||||
password: passwordController.text,
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
final result = await connection.connect(waitUntilLogin: true);
|
||||
setState(() {
|
||||
|
@ -6,6 +6,7 @@
|
||||
- Renamed `ResourceBindingSuccessEvent` to `ResourceBoundEvent`
|
||||
- **BREAKING**: Removed `isFeatureSupported` from the manager attributes. The managers now all have a method `isFeatureSupported` that works the same
|
||||
- The `PresenceManager` is now optional
|
||||
- **BREAKING**: Removed `setConnectionSettings` and `getConnectionSettings`. Just directly acces the `connectionSettings` field.
|
||||
|
||||
## 0.1.6+1
|
||||
|
||||
|
@ -119,7 +119,7 @@ class XmppConnection {
|
||||
late final Stream<String> _socketStream;
|
||||
|
||||
/// Connection settings
|
||||
late ConnectionSettings _connectionSettings;
|
||||
late ConnectionSettings connectionSettings;
|
||||
|
||||
/// A policy on how to reconnect
|
||||
final ReconnectionPolicy _reconnectionPolicy;
|
||||
@ -197,9 +197,9 @@ class XmppConnection {
|
||||
sendStanza: sendStanza,
|
||||
sendNonza: sendRawXML,
|
||||
sendEvent: _sendEvent,
|
||||
getConnectionSettings: () => _connectionSettings,
|
||||
getConnectionSettings: () => connectionSettings,
|
||||
getManagerById: getManagerById,
|
||||
getFullJID: () => _connectionSettings.jid.withResource(_resource),
|
||||
getFullJID: () => connectionSettings.jid.withResource(_resource),
|
||||
getSocket: () => _socket,
|
||||
getConnection: () => this,
|
||||
getNegotiatorById: _negotiationsHandler.getNegotiatorById,
|
||||
@ -246,11 +246,11 @@ class XmppConnection {
|
||||
NegotiatorAttributes(
|
||||
sendRawXML,
|
||||
() => this,
|
||||
() => _connectionSettings,
|
||||
() => connectionSettings,
|
||||
_sendEvent,
|
||||
_negotiationsHandler.getNegotiatorById,
|
||||
getManagerById,
|
||||
() => _connectionSettings.jid.withResource(_resource),
|
||||
() => connectionSettings.jid.withResource(_resource),
|
||||
() => _socket,
|
||||
() => _isAuthenticated,
|
||||
_setAuthenticated,
|
||||
@ -312,16 +312,6 @@ class XmppConnection {
|
||||
return getManagerById(csiManager);
|
||||
}
|
||||
|
||||
/// Set the connection settings of this connection.
|
||||
void setConnectionSettings(ConnectionSettings settings) {
|
||||
_connectionSettings = settings;
|
||||
}
|
||||
|
||||
/// Returns the connection settings of this connection.
|
||||
ConnectionSettings getConnectionSettings() {
|
||||
return _connectionSettings;
|
||||
}
|
||||
|
||||
/// Attempts to reconnect to the server by following an exponential backoff.
|
||||
Future<void> _attemptReconnection() async {
|
||||
_log.finest('_attemptReconnection: Setting state to notConnected');
|
||||
@ -471,14 +461,14 @@ class XmppConnection {
|
||||
case StanzaFromType.full:
|
||||
{
|
||||
stanza_ = stanza_.copyWith(
|
||||
from: _connectionSettings.jid.withResource(_resource).toString(),
|
||||
from: connectionSettings.jid.withResource(_resource).toString(),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case StanzaFromType.bare:
|
||||
{
|
||||
stanza_ = stanza_.copyWith(
|
||||
from: _connectionSettings.jid.toBare().toString(),
|
||||
from: connectionSettings.jid.toBare().toString(),
|
||||
);
|
||||
}
|
||||
break;
|
||||
@ -533,7 +523,7 @@ class XmppConnection {
|
||||
// A stanza with no to attribute is for direct processing by the server. As such,
|
||||
// we can correlate it by just *assuming* we have that attribute
|
||||
// (RFC 6120 Section 8.1.1.1)
|
||||
data.stanza.to ?? _connectionSettings.jid.toBare().toString(),
|
||||
data.stanza.to ?? connectionSettings.jid.toBare().toString(),
|
||||
data.stanza.id!,
|
||||
data.stanza.tag,
|
||||
);
|
||||
@ -752,7 +742,7 @@ class XmppConnection {
|
||||
|
||||
final awaited = await _stanzaAwaiter.onData(
|
||||
incomingPreHandlers.stanza,
|
||||
_connectionSettings.jid.toBare(),
|
||||
connectionSettings.jid.toBare(),
|
||||
);
|
||||
if (awaited) {
|
||||
return;
|
||||
@ -841,7 +831,7 @@ class XmppConnection {
|
||||
closeTag: false,
|
||||
isDeclaration: true,
|
||||
children: [
|
||||
StreamHeaderNonza(_connectionSettings.jid),
|
||||
StreamHeaderNonza(connectionSettings.jid),
|
||||
],
|
||||
).toXml(),
|
||||
);
|
||||
@ -929,20 +919,17 @@ class XmppConnection {
|
||||
}
|
||||
|
||||
final smManager = getStreamManagementManager();
|
||||
var host = _connectionSettings.host;
|
||||
var port = _connectionSettings.port;
|
||||
var host = connectionSettings.host;
|
||||
var port = connectionSettings.port;
|
||||
if (smManager?.state.streamResumptionLocation != null) {
|
||||
// TODO(Unknown): Maybe wrap this in a try catch?
|
||||
final parsed = Uri.parse(smManager!.state.streamResumptionLocation!);
|
||||
host = parsed.host;
|
||||
port = parsed.port;
|
||||
} else {
|
||||
host = _connectionSettings.host;
|
||||
port = _connectionSettings.port;
|
||||
}
|
||||
|
||||
final result = await _socket.connect(
|
||||
_connectionSettings.jid.domain,
|
||||
connectionSettings.jid.domain,
|
||||
host: host,
|
||||
port: port,
|
||||
);
|
||||
|
@ -72,12 +72,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
|
@ -161,7 +161,7 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
socket,
|
||||
);
|
||||
)..connectionSettings = TestingManagerHolder.settings;
|
||||
|
||||
await connection.registerManagers([
|
||||
PubSubManager(),
|
||||
@ -174,7 +174,6 @@ void main() {
|
||||
SaslPlainNegotiator(),
|
||||
ResourceBindingNegotiator(),
|
||||
]);
|
||||
connection.setConnectionSettings(TestingManagerHolder.settings);
|
||||
await connection.connect(
|
||||
waitUntilLogin: true,
|
||||
);
|
||||
|
@ -283,12 +283,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
final sm = StreamManagementManager();
|
||||
await conn.registerManagers([
|
||||
@ -409,12 +407,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
final sm = StreamManagementManager();
|
||||
await conn.registerManagers([
|
||||
@ -570,12 +566,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -665,12 +659,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -757,12 +749,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -846,12 +836,10 @@ void main() {
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)
|
||||
..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
)
|
||||
..setResource('test-resource', triggerEvent: false);
|
||||
await conn.registerManagers([
|
||||
@ -946,12 +934,10 @@ void main() {
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)
|
||||
..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
)
|
||||
..setResource('test-resource', triggerEvent: false);
|
||||
await conn.registerManagers([
|
||||
@ -1050,12 +1036,10 @@ void main() {
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)
|
||||
..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
)
|
||||
..setResource('test-resource', triggerEvent: false);
|
||||
await conn.registerManagers([
|
||||
|
@ -107,12 +107,10 @@ void main() {
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)
|
||||
..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
)
|
||||
..setResource('test-resource', triggerEvent: false);
|
||||
await conn.registerManagers([
|
||||
|
@ -171,12 +171,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
final csi = CSIManager();
|
||||
await csi.setInactive(sendNonza: false);
|
||||
|
@ -46,12 +46,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -120,12 +118,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
RosterManager(TestingRosterStateManager('', [])),
|
||||
|
@ -103,12 +103,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -184,12 +182,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -264,12 +260,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('user@server'),
|
||||
password: 'pencil',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -352,12 +346,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -438,12 +430,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
|
@ -109,12 +109,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
RosterManager(TestingRosterStateManager('', [])),
|
||||
@ -225,12 +223,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
RosterManager(TestingRosterStateManager('', [])),
|
||||
|
@ -127,12 +127,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -185,12 +183,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -245,12 +241,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
),
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -406,6 +400,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('testuser@example.org'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: false,
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
@ -416,13 +414,6 @@ void main() {
|
||||
// SaslPlainNegotiator(),
|
||||
ResourceBindingNegotiator(),
|
||||
]);
|
||||
conn.setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
jid: JID.fromString('testuser@example.org'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: false,
|
||||
),
|
||||
);
|
||||
|
||||
final result = await conn.connect(
|
||||
waitUntilLogin: true,
|
||||
@ -503,6 +494,10 @@ void main() {
|
||||
AlwaysConnectedConnectivityManager(),
|
||||
ClientToServerNegotiator(),
|
||||
fakeSocket,
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('testuser@example.org'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: false,
|
||||
);
|
||||
await conn.registerManagers([
|
||||
RosterManager(TestingRosterStateManager('', [])),
|
||||
@ -512,13 +507,6 @@ void main() {
|
||||
SaslPlainNegotiator(),
|
||||
ResourceBindingNegotiator(),
|
||||
]);
|
||||
conn.setConnectionSettings(
|
||||
ConnectionSettings(
|
||||
jid: JID.fromString('testuser@example.org'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: false,
|
||||
),
|
||||
);
|
||||
|
||||
final result1 = conn.connect(
|
||||
waitUntilLogin: true,
|
||||
|
Loading…
Reference in New Issue
Block a user