[tictactoe] Use extension point to add caps
This commit is contained in:
@@ -65,39 +65,34 @@ class TictactoePlugin(GajimPlugin):
|
|||||||
self.disconnect_from_chat_control),
|
self.disconnect_from_chat_control),
|
||||||
'chat_control_base_update_toolbar': (self.update_button_state,
|
'chat_control_base_update_toolbar': (self.update_button_state,
|
||||||
None),
|
None),
|
||||||
|
'update_caps': (self._update_caps, None),
|
||||||
}
|
}
|
||||||
self.config_default_values = {
|
self.config_default_values = {
|
||||||
'board_size': (5, ''),
|
'board_size': (5, ''),
|
||||||
}
|
}
|
||||||
self.controls = []
|
self.controls = []
|
||||||
|
self.announce_caps = True
|
||||||
|
|
||||||
@log_calls('TictactoePlugin')
|
@log_calls('TictactoePlugin')
|
||||||
def _compute_caps_hash(self):
|
def _update_caps(self, account):
|
||||||
for a in app.connections:
|
if not self.announce_caps:
|
||||||
app.caps_hash[a] = caps_cache.compute_caps_hash([
|
return
|
||||||
app.gajim_identity], app.gajim_common_features + \
|
if NS_GAMES not in app.gajim_optional_features[account]:
|
||||||
app.gajim_optional_features[a])
|
app.gajim_optional_features[account].append(NS_GAMES)
|
||||||
# re-send presence with new hash
|
if NS_GAMES_TICTACTOE not in app.gajim_optional_features[account]:
|
||||||
connected = app.connections[a].connected
|
app.gajim_optional_features[account].append(NS_GAMES_TICTACTOE)
|
||||||
if connected > 1 and app.SHOW_LIST[connected] != 'invisible':
|
|
||||||
app.connections[a].change_status(app.SHOW_LIST[connected],
|
|
||||||
app.connections[a].status)
|
|
||||||
|
|
||||||
@log_calls('TictactoePlugin')
|
@log_calls('TictactoePlugin')
|
||||||
def activate(self):
|
def activate(self):
|
||||||
if NS_GAMES not in app.gajim_common_features:
|
for account in app.caps_hash:
|
||||||
app.gajim_common_features.append(NS_GAMES)
|
if app.caps_hash[account] != '':
|
||||||
if NS_GAMES_TICTACTOE not in app.gajim_common_features:
|
self.announce_caps = True
|
||||||
app.gajim_common_features.append(NS_GAMES_TICTACTOE)
|
helpers.update_optional_features(account)
|
||||||
self._compute_caps_hash()
|
|
||||||
|
|
||||||
@log_calls('TictactoePlugin')
|
@log_calls('TictactoePlugin')
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
if NS_GAMES_TICTACTOE in app.gajim_common_features:
|
self.announce_caps = False
|
||||||
app.gajim_common_features.remove(NS_GAMES_TICTACTOE)
|
helpers.update_optional_features()
|
||||||
if NS_GAMES in app.gajim_common_features:
|
|
||||||
app.gajim_common_features.remove(NS_GAMES)
|
|
||||||
self._compute_caps_hash()
|
|
||||||
|
|
||||||
@log_calls('TictactoePlugin')
|
@log_calls('TictactoePlugin')
|
||||||
def connect_with_chat_control(self, control):
|
def connect_with_chat_control(self, control):
|
||||||
|
|||||||
Reference in New Issue
Block a user