Changeset 9548

Show
Ignore:
Timestamp:
04/30/08 04:55:13 (7 months ago)
Author:
bct
Message:

multiple chat session windows per contact. groupchat and pms broken.

Location:
branches/session_centric/src
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/session_centric/src/chat_control.py

    r9326 r9548  
    386386                        widget.disconnect(id) 
    387387                        del self.handlers[id] 
    388          
     388 
    389389        def connect_style_event(self, widget, set_fg = False, set_bg = False): 
    390390                self.disconnect_style_event(widget) 
     
    710710                kind in ('incoming', 'incoming_queue'): 
    711711                        self.parent_win.redraw_tab(self) 
    712                         ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account) 
    713712                        if not self.parent_win.is_active(): 
    714                                 self.parent_win.show_title(True, ctrl) # Enabled Urgent hint 
     713                                self.parent_win.show_title(True, self) # Enabled Urgent hint 
    715714                        else: 
    716                                 self.parent_win.show_title(False, ctrl) # Disabled Urgent hint 
     715                                self.parent_win.show_title(False, self) # Disabled Urgent hint 
    717716 
    718717        def toggle_emoticons(self): 
     
    906905                self.parent_win.window.is_active(): 
    907906                        # we are at the end 
    908                         if not gajim.events.remove_events(self.account, self.get_full_jid(), 
    909                         types = ['printed_' + type_, type_]): 
     907                        if not self.session.remove_events(['printed_' + type_, type_]): 
    910908                                # There were events to remove 
    911909                                self.redraw_after_event_removed(jid) 
     
    10201018                self.widget_set_visible(self.xml.get_widget('banner_eventbox'), 
    10211019                        gajim.config.get('hide_chat_banner')) 
    1022                  
     1020 
    10231021                # Add lock image to show chat encryption 
    10241022                self.lock_image = self.xml.get_widget('lock_image') 
    10251023                self.lock_tooltip = gtk.Tooltips() 
    1026                  
     1024 
    10271025                # keep timeout id and window obj for possible big avatar 
    10281026                # it is on enter-notify and leave-notify so no need to be per jid 
     
    10701068                        msg = _('GPG encryption enabled') 
    10711069                        ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 
    1072                          
     1070 
    10731071                        if self.session: 
    10741072                                self.session.loggable = gajim.config.get('log_encrypted_sessions') 
    10751073                        self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 
    10761074                                        self.session.is_loggable()) 
    1077                  
     1075 
    10781076                self.status_tooltip = gtk.Tooltips() 
    10791077                self.update_ui() 
     
    10941092                avatar_w = avatar_pixbuf.get_width() 
    10951093                avatar_h = avatar_pixbuf.get_height() 
    1096                  
     1094 
    10971095                scaled_buf = self.xml.get_widget('avatar_image').get_pixbuf() 
    10981096                scaled_buf_w = scaled_buf.get_width() 
    10991097                scaled_buf_h = scaled_buf.get_height() 
    1100                  
     1098 
    11011099                # do we have something bigger to show? 
    11021100                if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h: 
     
    11041102                        self.show_bigger_avatar_timeout_id = gobject.timeout_add(500, 
    11051103                                self.show_bigger_avatar, widget) 
    1106                  
     1104 
    11071105        def on_avatar_eventbox_leave_notify_event(self, widget, event): 
    11081106                '''we left the eventbox area that holds the avatar img''' 
     
    11231121                        menu.append(menuitem) 
    11241122                        menu.show_all() 
    1125                         menu.connect('selection-done', lambda w:w.destroy())     
     1123                        menu.connect('selection-done', lambda w:w.destroy()) 
    11261124                        # show the menu 
    11271125                        menu.show_all() 
     
    11901188                banner_name_label = self.xml.get_widget('banner_name_label') 
    11911189                banner_eventbox = self.xml.get_widget('banner_eventbox') 
    1192                  
     1190 
    11931191                name = contact.get_shown_name() 
    11941192                if self.resource: 
     
    12761274                        self.gpg_is_active = False 
    12771275                        msg = _('GPG encryption disabled') 
    1278                         ChatControlBase.print_conversation_line(self, msg, 'status', '', None)   
     1276                        ChatControlBase.print_conversation_line(self, msg, 'status', '', None) 
    12791277                        if self.session: 
    12801278                                self.session.loggable = True 
     
    13011299                gajim.config.set_per('contacts', self.contact.jid, 'gpg_enabled', 
    13021300                        self.gpg_is_active) 
    1303                  
     1301 
    13041302                self._show_lock_image(self.gpg_is_active, 'GPG', self.gpg_is_active, self.session and \ 
    13051303                                self.session.is_loggable()) 
    1306          
     1304 
    13071305        def _show_lock_image(self, visible, enc_type = '', enc_enabled = False, chat_logged = False): 
    13081306                '''Set lock icon visibiity and create tooltip'''  
     
    14681466                # True refresh 30 seconds vars too or else it's 30 - 5 = 25 seconds! 
    14691467                self.reset_kbd_mouse_timeout_vars() 
    1470                 return True # loop forever               
     1468                return True # loop forever 
    14711469 
    14721470        def check_for_possible_inactive_chatstate(self, arg): 
     
    16181616                else: # active or not chatstate, get color from gtk 
    16191617                        color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] 
    1620                  
     1618 
    16211619 
    16221620                name = self.contact.get_shown_name() 
     
    16371635                # Set tab image (always 16x16); unread messages show the 'event' image 
    16381636                tab_img = None 
    1639                  
     1637 
    16401638                if num_unread and gajim.config.get('show_unread_tab_icon'): 
    16411639                        img_16 = gajim.interface.roster.get_appropriate_state_images( 
     
    16731671                muc_icon = gajim.interface.roster.load_icon('muc_active') 
    16741672                if muc_icon: 
    1675                         convert_to_gc_menuitem.set_image(muc_icon)  
     1673                        convert_to_gc_menuitem.set_image(muc_icon) 
    16761674 
    16771675                ag = gtk.accel_groups_from_object(self.parent_win.window)[0] 
     
    16831681                contact = self.parent_win.get_active_contact() 
    16841682                jid = contact.jid 
    1685                  
     1683 
    16861684                # check if we support and use gpg 
    16871685                if not gajim.config.get_per('accounts', self.account, 'keyid') or\ 
     
    17661764                # this function checks for that and just returns so it's safe to call it 
    17671765                # with same state. 
    1768                  
     1766 
    17691767                # This functions also checks for violation in state transitions 
    17701768                # and raises RuntimeException with appropriate message 
     
    17951793                        return 
    17961794 
    1797                 # if the new state we wanna send (state) equals  
     1795                # if the new state we wanna send (state) equals 
    17981796                # the current state (contact.our_chatstate) then return 
    17991797                if contact.our_chatstate == state: 
     
    18071805                        # for that procedure so return to make sure we send only once 
    18081806                        # 'active' until we know peer supports jep85 
    1809                         return  
     1807                        return 
    18101808 
    18111809                if contact.our_chatstate == 'ask': 
     
    18271825                        contact.our_chatstate = 'active' 
    18281826                        self.reset_kbd_mouse_timeout_vars() 
    1829                  
     1827 
    18301828                # if we're inactive prevent composing (JEP violation) 
    18311829                elif contact.our_chatstate == 'inactive' and state == 'composing': 
     
    20532051                        self.print_esession_details() 
    20542052 
    2055                 # Is it a pm ? 
    2056                 is_pm = False 
    2057                 room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
    2058                 control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) 
    2059                 if control and control.type_id == message_control.TYPE_GC: 
    2060                         is_pm = True 
    20612053                # list of message ids which should be marked as read 
    20622054                message_ids = [] 
     
    20832075 
    20842076                typ = 'chat' # Is it a normal chat or a pm ? 
     2077 
    20852078                # reset to status image in gc if it is a pm 
    2086                 if is_pm: 
    2087                         control.update_ui() 
    2088                         control.parent_win.show_title() 
    2089                         typ = 'pm' 
     2079                # Is it a pm ? 
     2080                room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
     2081# XXX fixme somehow 
     2082#               control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) 
     2083#               if control and control.type_id == message_control.TYPE_GC: 
     2084#                       control.update_ui() 
     2085#                       control.parent_win.show_title() 
     2086#                       typ = 'pm' 
    20902087 
    20912088                self.redraw_after_event_removed(jid) 
     
    20982095                                gajim.interface.roster.really_remove_contact(self.contact, 
    20992096                                        self.account) 
    2100                         elif typ == 'pm': 
    2101                                 control.remove_contact(nick) 
     2097#                       elif typ == 'pm': 
     2098#                               control.remove_contact(nick) 
    21022099 
    21032100        def show_bigger_avatar(self, small_avatar): 
  • branches/session_centric/src/common/events.py

    r9307 r9548  
    117117        def remove_events(self, account, jid, event = None, types = []): 
    118118                '''if event is not specified, remove all events from this jid, 
    119                 optionnaly only from given type 
     119                optionally only from given type 
    120120                return True if no such event found''' 
    121121                if not self._events.has_key(account): 
  • branches/session_centric/src/message_window.py

    r9326 r9548  
    153153        def get_num_controls(self): 
    154154                n = 0 
    155                 for dict in self._controls.values(): 
    156                         n += len(dict) 
     155                for jid_dict in self._controls.values(): 
     156                        for dict in jid_dict.values(): 
     157                                n += len(dict) 
    157158                return n 
    158159 
     
    207208                        self._controls[control.account] = {} 
    208209                fjid = control.get_full_jid() 
    209                 self._controls[control.account][fjid] = control 
     210 
     211                if not self._controls[control.account].has_key(fjid): 
     212                        self._controls[control.account][fjid] = {} 
     213 
     214                self._controls[control.account][fjid][control.session.thread_id] = control 
    210215 
    211216                if self.get_num_controls() == 2: 
     
    392397                        gtkgui_helpers.set_unset_urgency_hint(self.window, False) 
    393398 
    394         def set_active_tab(self, jid, acct): 
    395                 ctrl = self._controls[acct][jid] 
     399        def set_active_tab(self, session): 
     400                ctrl = self._controls[session.conn.name][session.jid][session.thread_id] 
    396401                ctrl_page = self.notebook.page_num(ctrl.widget) 
    397402                self.notebook.set_current_page(ctrl_page) 
     
    425430 
    426431                fjid = ctrl.get_full_jid() 
    427                 del self._controls[ctrl.account][fjid] 
     432                thread_id = ctrl.session.thread_id 
     433                del self._controls[ctrl.account][fjid][thread_id] 
     434 
     435                if len(self._controls[ctrl.account][fjid]) == 0: 
     436                        del self._controls[ctrl.account][fjid] 
     437 
    428438                if len(self._controls[ctrl.account]) == 0: 
    429439                        del self._controls[ctrl.account] 
     
    564574 
    565575        def controls(self): 
    566                 for ctrl_dict in self._controls.values(): 
    567                         for ctrl in ctrl_dict.values(): 
    568                                 yield ctrl 
     576                for jid_dict in self._controls.values(): 
     577                        for ctrl_dict in jid_dict.values(): 
     578                                for ctrl in ctrl_dict.values(): 
     579                                        yield ctrl 
    569580 
    570581        def move_to_next_unread_tab(self, forward): 
  • branches/session_centric/src/roster_window.py

    r9459 r9548  
    43134313                        session = conn.get_session(fjid, None, 'chat') 
    43144314 
    4315                 win = gajim.interface.msg_win_mgr.get_window(fjid, account) 
    4316                 if not win: 
     4315                if not session.control: 
    43174316                        session.control = self.new_chat(session, contact, account, resource=resource) 
    43184317 
     
    43204319                                session.control.read_queue() 
    43214320 
    4322                         win = gajim.interface.msg_win_mgr.get_window(fjid, account) 
    43234321                        # last message is long time ago 
    43244322                        gajim.last_message_time[account][session.control.get_full_jid()] = 0 
    43254323 
    4326                 win.set_active_tab(fjid, account) 
     4324                win = session.control.parent_win 
     4325                win.set_active_tab(session) 
     4326 
    43274327                if conn.is_zeroconf and conn.status in ('offline', 'invisible'): 
    43284328                        win.get_control(fjid, account).got_disconnected() 
     
    52055205                elif nb_unread == 1: 
    52065206                        start = '*  ' 
     5207 
    52075208                self.window.set_title(start + 'Gajim') 
    52085209 
  • branches/session_centric/src/session.py

    r9465 r9548  
    1919 
    2020                self.control = None 
     21 
     22        # remove events associated with this session from the queue 
     23        def remove_events(self, types): 
     24                any_removed = False 
     25 
     26                for event in gajim.events.get_events(self.conn, self.jid, types=types): 
     27                        if event.parameters[8] != self: 
     28                                continue 
     29 
     30                        r = gajim.events.remove_events(self.conn, self.jid, event) 
     31 
     32                        if not_any_removed: 
     33                                any_removed = r 
     34 
     35                return any_removed 
    2136 
    2237        # extracts chatstate from a <message/> stanza 
     
    94109 
    95110                groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name) 
    96                 if not groupchat_control and \ 
    97                 jid in gajim.interface.minimized_controls[self.conn.name]: 
    98                         groupchat_control = self.minimized_controls[self.conn.name][jid] 
     111 
     112# XXX fixme 
     113#               if not groupchat_control and \ 
     114#               jid in gajim.interface.minimized_controls[self.conn.name]: 
     115#                       groupchat_control = self.minimized_controls[self.conn.name][jid] 
    99116 
    100117                pm = False 
    101                 if groupchat_control and groupchat_control.type_id == \ 
    102                 message_control.TYPE_GC: 
     118#               if groupchat_control and groupchat_control.type_id == \ 
     119#               message_control.TYPE_GC: 
    103120                        # It's a Private message 
    104                         pm = True 
    105                         msg_type = 'pm' 
     121#                       pm = True 
     122#                       msg_type = 'pm' 
    106123 
    107124                jid_of_control = full_jid_with_resource 
     
    185202        subject=None, resource='', msg_id=None, user_nick='', 
    186203        advanced_notif_num=None, xhtml=None, form_node=None): 
     204 
    187205                contact = None 
    188206                # if chat window will be for specific resource