aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/connection_manager.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-30 01:43:26 +0100
committerfiaxh <git@mx.ax.lt>2017-10-31 17:32:48 +0100
commitd82194af58c8ff92634ce57ef293894ec4422efa (patch)
tree17208ffd0b57dfa131e91d351c38cd75d2ad7ea7 /libdino/src/service/connection_manager.vala
parent0102abeec1d2055b19dccbb7edc7f06e527642b1 (diff)
downloaddino-d82194af58c8ff92634ce57ef293894ec4422efa.tar.gz
dino-d82194af58c8ff92634ce57ef293894ec4422efa.zip
Go offline before quiting application
fixes #141
Diffstat (limited to 'libdino/src/service/connection_manager.vala')
-rw-r--r--libdino/src/service/connection_manager.vala25
1 files changed, 20 insertions, 5 deletions
diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala
index 60cd335a..4c72f229 100644
--- a/libdino/src/service/connection_manager.vala
+++ b/libdino/src/service/connection_manager.vala
@@ -130,14 +130,29 @@ public class ConnectionManager {
return null;
}
- public void disconnect(Account account) {
+ public void make_offline_all() {
+ foreach (Account account in connection_todo) {
+ make_offline(account);
+ }
+ }
+
+ private void make_offline(Account account) {
+ Xmpp.Presence.Stanza presence = new Xmpp.Presence.Stanza();
+ presence.type_ = Xmpp.Presence.Stanza.TYPE_UNAVAILABLE;
change_connection_state(account, ConnectionState.DISCONNECTED);
+ try {
+ connections[account].stream.get_module(Presence.Module.IDENTITY).send_presence(connections[account].stream, presence);
+ } catch (Error e) { print(@"on_prepare_for_sleep error $(e.message)\n"); }
+ }
+
+ public void disconnect(Account account) {
+ make_offline(account);
+ try {
+ connections[account].stream.disconnect();
+ } catch (Error e) { print(@"on_prepare_for_sleep error $(e.message)\n"); }
connection_todo.remove(account);
if (connections.has_key(account)) {
- try {
- connections[account].stream.disconnect();
- connections.unset(account);
- } catch (Error e) { }
+ connections.unset(account);
}
}