[polari/gnome-3-32] telepathyClient: Use :reachable for connectivity
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/gnome-3-32] telepathyClient: Use :reachable for connectivity
- Date: Sun, 12 May 2019 20:47:09 +0000 (UTC)
commit eb54b5d721aad6bd1d779d9c3d9e7b94bd4072b0
Author: Florian Müllner <fmuellner gnome org>
Date: Sun May 12 13:06:47 2019 +0200
telepathyClient: Use :reachable for connectivity
GNetworkManager:network-available uses a very generous definition of
"available", which doesn't necessarily imply that we can actually
establish a connection to any server.
The new Account:reachable property is much more specific and thus
provides a much more adequate state.
https://gitlab.gnome.org/GNOME/polari/merge_requests/120
src/telepathyClient.js | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index ccd7a87..4137b5b 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -125,7 +125,6 @@ class TelepathyClient extends Tp.BaseClient {
this.set_handler_bypass_approval(false);
this.set_observer_recover(true);
- this._networkMonitor = Gio.NetworkMonitor.get_default();
this._roomManager = RoomManager.getDefault();
this._roomManager.connect('room-added', (mgr, room) => {
if (room.account.connection)
@@ -232,33 +231,22 @@ class TelepathyClient extends Tp.BaseClient {
this._accountsMonitor.connect('account-status-changed',
this._onAccountStatusChanged.bind(this));
- this._accountsMonitor.connect('account-added', (mon, account) => {
- this._connectAccount(account);
- });
- this._accountsMonitor.connect('account-shown', (mon, account) => {
- this._connectAccount(account);
- });
+ this._accountsMonitor.connect('account-reachable-changed',
+ this._onAccountReachableChanged.bind(this));
this._accountsMonitor.visibleAccounts.forEach(a => {
this._onAccountStatusChanged(this._accountsMonitor, a);
});
-
- this._networkMonitor.connect('network-changed',
- this._onNetworkChanged.bind(this));
- if (this._networkMonitor.state_valid) {
- this._onNetworkChanged(this._networkMonitor,
- this._networkMonitor.network_available);
- }
}
- _onNetworkChanged(mon, connected) {
- let presence = connected ?
- Tp.ConnectionPresenceType.AVAILABLE :
- Tp.ConnectionPresenceType.OFFLINE;
- debug(`Network changed to ${connected ? 'available' : 'unavailable'}`);
+ _onAccountReachableChanged(mon, account) {
+ let presence = account.reachable
+ ? Tp.ConnectionPresenceType.AVAILABLE
+ : Tp.ConnectionPresenceType.OFFLINE;
+ debug(`Account ${account.display_name} is now ${account.reachable
+ ? 'reachable'
+ : 'unreachable'}`);
- this._accountsMonitor.visibleAccounts.forEach(a => {
- this._setAccountPresence(a, presence);
- });
+ this._setAccountPresence(account, presence);
}
_onAccountStatusChanged(mon, account) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]