Browse Source

device: move cleanup after channel is closed to single place

bboozzoo/device-cache
Maciek Borzecki 10 years ago
parent
commit
94441d1ec4
1 changed files with 12 additions and 8 deletions
  1. +12
    -8
      src/device.vala

+ 12
- 8
src/device.vala View File

@ -138,9 +138,9 @@ class Device : Object {
public void deactivate() {
if (_channel != null)
_channel.close.begin();
_channel = null;
_host = null;
_channel.close.begin((c) => {
channel_closed_cleanup();
});
}
/**
@ -169,13 +169,13 @@ class Device : Object {
}
}
private void channel_openend(bool result) {
debug("channel openend: %s", result.to_string());
if (result == true) {
greet();
greet.begin();
} else {
_channel = null;
// failed to open channel, invoke cleanup
channel_closed_cleanup();
}
}
@ -230,10 +230,14 @@ class Device : Object {
paired(is_paired);
}
private async void handle_disconnect() {
private void handle_disconnect() {
// channel got disconnected
debug("channel disconnected");
yield _channel.close();
_channel.close.begin((c) => {
channel_closed_cleanup();
});
}
private void channel_closed_cleanup() {
_channel = null;
_host = null;
// emit disconnected


Loading…
Cancel
Save