Added a function to check for specific features. This makes
implementing a later coming fallback to disco rather easy.
This commit is contained in:
parent
38760989d1
commit
0405981b15
|
@ -1074,15 +1074,13 @@ class ChatControl(ChatControlBase):
|
|||
|
||||
# If we don't have resource, we can't do file transfer
|
||||
# in transports, contact holds our info we need to disable it too
|
||||
if NS_FILE in gajim.capscache[(contact.caps_hash_method,
|
||||
contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_FILE):
|
||||
send_file_button.set_sensitive(True)
|
||||
else:
|
||||
send_file_button.set_sensitive(False)
|
||||
|
||||
# check if it's possible to convert to groupchat
|
||||
if NS_MUC in gajim.capscache[(contact.caps_hash_method,
|
||||
contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_MUC):
|
||||
convert_to_gc_button.set_sensitive(True)
|
||||
else:
|
||||
convert_to_gc_button.set_sensitive(False)
|
||||
|
@ -1821,15 +1819,13 @@ class ChatControl(ChatControlBase):
|
|||
|
||||
# If we don't have resource, we can't do file transfer
|
||||
# in transports, contact holds our info we need to disable it too
|
||||
if NS_FILE in gajim.capscache[(contact.caps_hash_method,
|
||||
contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_FILE):
|
||||
send_file_menuitem.set_sensitive(True)
|
||||
else:
|
||||
send_file_menuitem.set_sensitive(False)
|
||||
|
||||
# check if it's possible to convert to groupchat
|
||||
if NS_MUC in gajim.capscache[(contact.caps_hash_method,
|
||||
contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_MUC):
|
||||
convert_to_gc_menuitem.set_sensitive(True)
|
||||
else:
|
||||
convert_to_gc_menuitem.set_sensitive(False)
|
||||
|
|
|
@ -178,6 +178,21 @@ class CapsCache(object):
|
|||
# this will create proper object
|
||||
q.queried=1
|
||||
con.discoverInfo(jid, '%s#%s' % (node, hash))
|
||||
|
||||
def is_supported(self, contact, feature):
|
||||
if not contact.resource:
|
||||
return False
|
||||
|
||||
# FIXME: We assume everything is supported if we got no caps.
|
||||
# This is the "Asterix way", after 0.12 release, I will
|
||||
# likely implement a fallback to disco (could be disabled
|
||||
# for mobile users who pay for traffic)
|
||||
features = self[(contact.caps_hash_method,
|
||||
contact.caps_hash)].features
|
||||
if feature in features or features == []:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
gajim.capscache = CapsCache(gajim.logger)
|
||||
|
||||
|
|
|
@ -4884,8 +4884,7 @@ class RosterWindow:
|
|||
start_chat_menuitem.connect('activate',
|
||||
self.on_roster_treeview_row_activated, tree_path)
|
||||
|
||||
if contact.resource and NS_FILE in gajim.capscache[
|
||||
(contact.caps_hash_method, contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_FILE):
|
||||
send_file_menuitem.set_sensitive(True)
|
||||
send_file_menuitem.connect('activate',
|
||||
self.on_send_file_menuitem_activate, contact, account)
|
||||
|
@ -5048,8 +5047,7 @@ class RosterWindow:
|
|||
else: # one resource
|
||||
start_chat_menuitem.connect('activate',
|
||||
gajim.interface.on_open_chat_window, contact, account)
|
||||
if contact.resource and NS_COMMANDS in gajim.capscache[
|
||||
(contact.caps_hash_method, contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_COMMANDS):
|
||||
execute_command_menuitem.set_sensitive(True)
|
||||
execute_command_menuitem.connect('activate', self.on_execute_command,
|
||||
contact, account, contact.resource)
|
||||
|
@ -5062,8 +5060,7 @@ class RosterWindow:
|
|||
our_jid_other_resource = contact.resource
|
||||
# Else this var is useless but harmless in next connect calls
|
||||
|
||||
if contact.resource and NS_FILE in gajim.capscache[
|
||||
(contact.caps_hash_method, contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_FILE):
|
||||
send_file_menuitem.set_sensitive(True)
|
||||
send_file_menuitem.connect('activate',
|
||||
self.on_send_file_menuitem_activate, contact, account)
|
||||
|
@ -5479,8 +5476,8 @@ class RosterWindow:
|
|||
item.connect('activate', action, [(c, account)], c.resource)
|
||||
else: # start_chat, execute_command, send_file
|
||||
item.connect('activate', action, c, account, c.resource)
|
||||
if cap and cap not in gajim.capscache[
|
||||
(c.caps_hash_method, c.caps_hash)].features:
|
||||
if cap and \
|
||||
not gajim.capscache.is_supported(c, cap):
|
||||
item.set_sensitive(False)
|
||||
return sub_menu
|
||||
|
||||
|
@ -5516,8 +5513,7 @@ class RosterWindow:
|
|||
invite_to_new_room_menuitem.set_submenu(self.build_resources_submenu(
|
||||
contact_list, account, self.on_invite_to_new_room, cap=NS_MUC))
|
||||
else:
|
||||
if NS_MUC in gajim.capscache[(contact.caps_hash_method,
|
||||
contact.caps_hash)].features:
|
||||
if gajim.capscache.is_supported(contact, NS_MUC):
|
||||
invite_menuitem.set_sensitive(True)
|
||||
invite_to_new_room_menuitem.connect('activate',
|
||||
self.on_invite_to_new_room, list_)
|
||||
|
|
Loading…
Reference in New Issue