Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <forenjunkie@chello.at>2017-11-16 01:37:50 +0300
committerPhilipp Hörist <forenjunkie@chello.at>2017-11-16 01:45:22 +0300
commitf15fab4a2a8dc605176e260c9ca1cb331dfc92ee (patch)
tree5d428e71926f0c3dfc03e81c884055a6b84f4366
parent45f129ceb38679dbd96225c1a1b42a03b2a6d627 (diff)
[tictactoe] Use extension point to add caps
-rw-r--r--tictactoe/plugin.py35
1 files changed, 15 insertions, 20 deletions
diff --git a/tictactoe/plugin.py b/tictactoe/plugin.py
index b929a3a..16d21da 100644
--- a/tictactoe/plugin.py
+++ b/tictactoe/plugin.py
@@ -65,39 +65,34 @@ class TictactoePlugin(GajimPlugin):
self.disconnect_from_chat_control),
'chat_control_base_update_toolbar': (self.update_button_state,
None),
+ 'update_caps': (self._update_caps, None),
}
self.config_default_values = {
'board_size': (5, ''),
}
self.controls = []
+ self.announce_caps = True
@log_calls('TictactoePlugin')
- def _compute_caps_hash(self):
- for a in app.connections:
- app.caps_hash[a] = caps_cache.compute_caps_hash([
- app.gajim_identity], app.gajim_common_features + \
- app.gajim_optional_features[a])
- # re-send presence with new hash
- connected = app.connections[a].connected
- if connected > 1 and app.SHOW_LIST[connected] != 'invisible':
- app.connections[a].change_status(app.SHOW_LIST[connected],
- app.connections[a].status)
+ def _update_caps(self, account):
+ if not self.announce_caps:
+ return
+ if NS_GAMES not in app.gajim_optional_features[account]:
+ app.gajim_optional_features[account].append(NS_GAMES)
+ if NS_GAMES_TICTACTOE not in app.gajim_optional_features[account]:
+ app.gajim_optional_features[account].append(NS_GAMES_TICTACTOE)
@log_calls('TictactoePlugin')
def activate(self):
- if NS_GAMES not in app.gajim_common_features:
- app.gajim_common_features.append(NS_GAMES)
- if NS_GAMES_TICTACTOE not in app.gajim_common_features:
- app.gajim_common_features.append(NS_GAMES_TICTACTOE)
- self._compute_caps_hash()
+ for account in app.caps_hash:
+ if app.caps_hash[account] != '':
+ self.announce_caps = True
+ helpers.update_optional_features(account)
@log_calls('TictactoePlugin')
def deactivate(self):
- if NS_GAMES_TICTACTOE in app.gajim_common_features:
- app.gajim_common_features.remove(NS_GAMES_TICTACTOE)
- if NS_GAMES in app.gajim_common_features:
- app.gajim_common_features.remove(NS_GAMES)
- self._compute_caps_hash()
+ self.announce_caps = False
+ helpers.update_optional_features()
@log_calls('TictactoePlugin')
def connect_with_chat_control(self, control):