Changeset 9873

Show
Ignore:
Timestamp:
07/02/08 11:20:49 (5 months ago)
Author:
js
Message:

Added a function to check for specific features. This makes
implementing a later coming fallback to disco rather easy.

Location:
trunk/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chat_control.py

    r9871 r9873  
    10751075                # If we don't have resource, we can't do file transfer 
    10761076                # in transports, contact holds our info we need to disable it too 
    1077                 if NS_FILE in gajim.capscache[(contact.caps_hash_method, 
    1078                 contact.caps_hash)].features: 
     1077                if gajim.capscache.is_supported(contact, NS_FILE): 
    10791078                        send_file_button.set_sensitive(True) 
    10801079                else: 
     
    10821081 
    10831082                # check if it's possible to convert to groupchat 
    1084                 if NS_MUC in gajim.capscache[(contact.caps_hash_method, 
    1085                 contact.caps_hash)].features: 
     1083                if gajim.capscache.is_supported(contact, NS_MUC): 
    10861084                        convert_to_gc_button.set_sensitive(True) 
    10871085                else: 
     
    18221820                # If we don't have resource, we can't do file transfer 
    18231821                # in transports, contact holds our info we need to disable it too 
    1824                 if NS_FILE in gajim.capscache[(contact.caps_hash_method, 
    1825                 contact.caps_hash)].features: 
     1822                if gajim.capscache.is_supported(contact, NS_FILE): 
    18261823                        send_file_menuitem.set_sensitive(True) 
    18271824                else: 
     
    18291826 
    18301827                # check if it's possible to convert to groupchat 
    1831                 if NS_MUC in gajim.capscache[(contact.caps_hash_method, 
    1832                 contact.caps_hash)].features: 
     1828                if gajim.capscache.is_supported(contact, NS_MUC): 
    18331829                        convert_to_gc_menuitem.set_sensitive(True) 
    18341830                else: 
  • trunk/src/common/caps.py

    r9854 r9873  
    179179                        q.queried=1 
    180180                        con.discoverInfo(jid, '%s#%s' % (node, hash)) 
     181         
     182        def is_supported(self, contact, feature): 
     183                if not contact.resource: 
     184                        return False 
     185 
     186                # FIXME: We assume everything is supported if we got no caps. 
     187                #        This is the "Asterix way", after 0.12 release, I will 
     188                #        likely implement a fallback to disco (could be disabled 
     189                #        for mobile users who pay for traffic) 
     190                features = self[(contact.caps_hash_method, 
     191                        contact.caps_hash)].features 
     192                if feature in features or features == []: 
     193                        return True 
     194 
     195                return False 
    181196 
    182197gajim.capscache = CapsCache(gajim.logger) 
  • trunk/src/roster_window.py

    r9872 r9873  
    48854885                                        self.on_roster_treeview_row_activated, tree_path) 
    48864886 
    4887                         if contact.resource and NS_FILE in gajim.capscache[ 
    4888                         (contact.caps_hash_method, contact.caps_hash)].features: 
     4887                        if gajim.capscache.is_supported(contact, NS_FILE): 
    48894888                                send_file_menuitem.set_sensitive(True) 
    48904889                                send_file_menuitem.connect('activate', 
     
    50495048                        start_chat_menuitem.connect('activate', 
    50505049                                gajim.interface.on_open_chat_window, contact, account) 
    5051                         if contact.resource and NS_COMMANDS in gajim.capscache[ 
    5052                         (contact.caps_hash_method, contact.caps_hash)].features: 
     5050                        if gajim.capscache.is_supported(contact, NS_COMMANDS): 
    50535051                                execute_command_menuitem.set_sensitive(True) 
    50545052                                execute_command_menuitem.connect('activate', self.on_execute_command, 
     
    50635061                        # Else this var is useless but harmless in next connect calls 
    50645062 
    5065                         if contact.resource and NS_FILE in gajim.capscache[ 
    5066                         (contact.caps_hash_method, contact.caps_hash)].features: 
     5063                        if gajim.capscache.is_supported(contact, NS_FILE): 
    50675064                                send_file_menuitem.set_sensitive(True) 
    50685065                                send_file_menuitem.connect('activate', 
     
    54805477                        else: # start_chat, execute_command, send_file 
    54815478                                item.connect('activate', action, c, account, c.resource) 
    5482                         if cap and cap not in gajim.capscache[ 
    5483                         (c.caps_hash_method, c.caps_hash)].features: 
     5479                        if cap and \ 
     5480                        not gajim.capscache.is_supported(c, cap): 
    54845481                                item.set_sensitive(False) 
    54855482                return sub_menu 
     
    55175514                                contact_list, account, self.on_invite_to_new_room, cap=NS_MUC)) 
    55185515                else: 
    5519                         if NS_MUC in gajim.capscache[(contact.caps_hash_method, 
    5520                         contact.caps_hash)].features: 
     5516                        if gajim.capscache.is_supported(contact, NS_MUC): 
    55215517                                invite_menuitem.set_sensitive(True) 
    55225518                                invite_to_new_room_menuitem.connect('activate',