Changeset 9953

Show
Ignore:
Timestamp:
07/18/08 22:24:34 (7 weeks ago)
Author:
js
Message:

Support for displaying XEP-0184 receipts.

Location:
trunk
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chat_control.py

    r9940 r9953  
    4646constants = Constants() 
    4747from common.rst_xhtml_generator import create_xhtml 
    48 from common.xmpp.protocol import NS_XHTML, NS_FILE, NS_MUC, NS_ESESSION 
     48from common.xmpp.protocol import NS_XHTML, NS_FILE, NS_MUC, NS_RECEIPTS, NS_ESESSION 
    4949 
    5050try: 
     
    661661        def print_conversation_line(self, text, kind, name, tim, 
    662662        other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[], 
    663         count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False): 
     663        count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False, xep0184_id = None): 
    664664                '''prints 'chat' type messages''' 
    665665                jid = self.contact.jid 
     
    672672                        other_tags_for_name, other_tags_for_time, other_tags_for_text, 
    673673                        subject, old_kind, xhtml, simple=simple) 
     674 
     675                if xep0184_id is not None: 
     676                        textview.show_xep0184_warning(xep0184_id) 
    674677 
    675678                if not count_as_new: 
     
    15391542                                self._schedule_activity_timers() 
    15401543 
    1541                 if ChatControlBase.send_message(self, message, keyID, 
    1542                 type = 'chat', chatstate = chatstate_to_send, 
    1543                 composing_xep = composing_xep, 
    1544                 process_command = process_command): 
     1544                id = ChatControlBase.send_message(self, message, keyID, 
     1545                        type = 'chat', chatstate = chatstate_to_send, 
     1546                        composing_xep = composing_xep, 
     1547                        process_command = process_command) 
     1548                if id: 
     1549                        # XXX: Once we have fallback to disco, remove 
     1550                        #      notexistant check 
     1551                        if gajim.capscache.is_supported(contact, NS_RECEIPTS) \ 
     1552                        and not gajim.capscache.is_supported(contact, 
     1553                        'notexistant') and gajim.config.get_per('accounts', 
     1554                        self.account, 'request_receipt'): 
     1555                                xep0184_id = id 
     1556                        else: 
     1557                                xep0184_id = None 
     1558 
    15451559                        self.print_conversation(message, self.contact.jid, 
    1546                                 encrypted = encrypted) 
     1560                                encrypted = encrypted, xep0184_id = xep0184_id) 
    15471561 
    15481562        def check_for_possible_paused_chatstate(self, arg): 
     
    16301644 
    16311645        def print_conversation(self, text, frm='', tim=None, encrypted=False, 
    1632         subject=None, xhtml=None, simple=False): 
     1646        subject=None, xhtml=None, simple=False, xep0184_id=None): 
    16331647                # TODO: contact? ITYM frm. 
    16341648                '''Print a line in the conversation: 
     
    16841698                ChatControlBase.print_conversation_line(self, text, kind, name, tim, 
    16851699                        subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml, 
    1686                         simple=simple) 
     1700                        simple=simple, xep0184_id=xep0184_id) 
    16871701                if text.startswith('/me ') or text.startswith('/me\n'): 
    16881702                        self.old_msg_kind = None 
  • trunk/src/common/connection_handlers.py

    r9925 r9953  
    17301730                        con.send(receipt) 
    17311731 
     1732                # We got our message's receipt 
     1733                if msg.getTag('received', namespace=common.xmpp.NS_RECEIPTS) \ 
     1734                and session.control and gajim.config.get_per('accounts', 
     1735                self.name, 'request_receipt'): 
     1736                        session.control.conv_textview.hide_xep0184_warning( 
     1737                                msg.getID()) 
     1738 
    17321739                addressTag = msg.getTag('addresses', namespace = common.xmpp.NS_ADDRESS) 
    17331740 
  • trunk/src/conversation_textview.py

    r9898 r9953  
    149149        for chat/groupchat windows''' 
    150150 
    151         path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps', 'muc_separator.png') 
    152         FOCUS_OUT_LINE_PIXBUF = gtk.gdk.pixbuf_new_from_file(path_to_file) 
     151        FOCUS_OUT_LINE_PIXBUF = gtk.gdk.pixbuf_new_from_file(os.path.join( 
     152                gajim.DATA_DIR, 'pixmaps', 'muc_separator.png')) 
     153        XEP0184_WARNING_PIXBUF = gtk.gdk.pixbuf_new_from_file(os.path.join( 
     154                gajim.DATA_DIR, 'pixmaps', 'xep0184.png')) 
    153155 
    154156        # smooth scroll constants 
     
    176178                self.images = [] 
    177179                self.image_cache = {} 
     180                self.xep0184_marks = {} 
    178181 
    179182                # It's True when we scroll in the code, so we can detect scroll from user 
     
    389392                        self.smooth_id = None 
    390393                        self.smooth_scroll_timer.cancel() 
     394 
     395        def show_xep0184_warning(self, id): 
     396                try: 
     397                        if self.xep0184_marks[id] is not None: 
     398                                return 
     399                except KeyError: 
     400                        pass 
     401 
     402                buffer = self.tv.get_buffer() 
     403 
     404                buffer.begin_user_action() 
     405 
     406                end_iter = buffer.get_end_iter() 
     407                buffer.insert(end_iter, ' ') 
     408                buffer.insert_pixbuf(end_iter, 
     409                        ConversationTextview.XEP0184_WARNING_PIXBUF) 
     410 
     411                end_iter = buffer.get_end_iter(); 
     412                before_img_iter = end_iter.copy() 
     413                # XXX: Is there a nicer way? 
     414                before_img_iter.backward_char(); 
     415                before_img_iter.backward_char(); 
     416 
     417                self.xep0184_marks[id] = buffer.create_mark(None, 
     418                        buffer.get_end_iter(), left_gravity=True) 
     419 
     420                buffer.end_user_action() 
     421 
     422        def hide_xep0184_warning(self, id): 
     423                try: 
     424                        if self.xep0184_marks[id] is None: 
     425                                return 
     426                except KeyError: 
     427                        return 
     428 
     429                buffer = self.tv.get_buffer() 
     430 
     431                buffer.begin_user_action() 
     432 
     433                end_iter = buffer.get_iter_at_mark(self.xep0184_marks[id]) 
     434 
     435                begin_iter = end_iter.copy() 
     436                # XXX: Is there a nicer way? 
     437                begin_iter.backward_char(); 
     438                begin_iter.backward_char(); 
     439 
     440                buffer.delete(begin_iter, end_iter) 
     441                buffer.delete_mark(self.xep0184_marks[id]) 
     442 
     443                buffer.end_user_action() 
     444 
     445                self.xep0184_marks[id] = None 
    391446 
    392447        def show_focus_out_line(self): 
  • trunk/src/message_control.py

    r9951 r9953  
    168168                # Send and update history 
    169169                return conn.send_message(jid, message, keyID, type = type, 
    170                         chatstate = chatstate, msg_id = msg_id, composing_xep = composing_xep, 
     170                        chatstate = chatstate, msg_id = msg_id, 
     171                        composing_xep = composing_xep, 
    171172                        resource = self.resource, user_nick = user_nick, 
    172                         session = self.session, original_message = original_message) 
     173                        session = self.session, 
     174                        original_message = original_message)