Show
Ignore:
Timestamp:
07/19/05 16:38:58 (3 years ago)
Author:
nk
Message:

[peralta] Chat State Notifications inital patch. I assume that every wm will focus-out before iconify. If that is not the case I am going to use window-state-changed too [to be tested]

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common/connection.py

    r2386 r2399  
    219219                tim = time.localtime(timegm(tim)) 
    220220                encrypted = False 
     221                chatstate_tag = None 
    221222                xtags = msg.getTags('x') 
    222223                encTag = None 
     
    226227                                encTag = xtag 
    227228                                break 
     229 
     230                # chatstates - look for chatstate tags in a message 
     231                children = msg.getChildren() 
     232                for child in children: 
     233                        if child.getNamespace() == 'http://jabber.org/protocol/chatstates': 
     234                                chatstate_tag = child.getName() 
     235                                break 
     236                         
    228237                if encTag and USE_GPG: 
    229238                        #decrypt 
     
    254263                                tim = tim) 
    255264                        self.dispatch('MSG', (str(msg.getFrom()), msgtxt, tim, encrypted, 
    256                                 mtype, subject)) 
     265                                mtype, subject, None)) 
    257266                else: # it's type 'chat' 
    258                         if not msg.getTag('body'): #no <body> 
     267                        if not msg.getTag('body') and chatstate_tag is None: #no <body> 
    259268                                return 
    260269                        log_msgtxt = msgtxt 
     
    264273                                tim = tim) 
    265274                        self.dispatch('MSG', (str(msg.getFrom()), msgtxt, tim, encrypted, 
    266                                 mtype, subject)) 
     275                                mtype, subject, chatstate_tag)) 
    267276        # END messageCB 
    268277 
     
    860869                        self.dispatch('STATUS', show) 
    861870 
    862         def send_message(self, jid, msg, keyID, type = 'chat', subject=''): 
    863                 if not self.connection: 
    864                         return 
    865                 if not msg: 
     871        def send_message(self, jid, msg, keyID, type = 'chat', subject='', chatstate = None): 
     872                if not self.connection: 
     873                        return 
     874                if not msg and chatstate is None: 
    866875                        return 
    867876                msgtxt = msg 
     
    887896                if msgenc: 
    888897                        msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc) 
     898 
     899                # chatstates - if peer supports jep85, send chatstates 
     900                # please note that the only valid tag inside a message containing a <body> tag is the active event 
     901                if chatstate != None: 
     902                        msg_iq.setTag(chatstate, {}, namespace='http://jabber.org/protocol/chatstates') 
     903                 
    889904                self.to_be_sent.append(msg_iq) 
    890905                gajim.logger.write('outgoing', msg, jid) 
     
    940955                return 
    941956 
    942         def update_user(self, jid, name, groups): 
     957        def update_contact(self, jid, name, groups): 
    943958                if self.connection: 
    944959                        self.connection.getRoster().setItem(jid = jid, name = name, 
     
    11511166 
    11521167        def gc_set_role(self, room_jid, nick, role, reason = ''): 
     1168                '''role is for all the life of the room so it's based on nick''' 
    11531169                if not self.connection: 
    11541170                        return 
     
    11631179 
    11641180        def gc_set_affiliation(self, room_jid, jid, affiliation, reason = ''): 
     1181                '''affiliation is for all the life of the room so it's based on jid''' 
    11651182                if not self.connection: 
    11661183                        return