Changeset 9567

Show
Ignore:
Timestamp:
05/03/08 18:52:27 (7 months ago)
Author:
bct
Message:

reuse existing chat sessions and controls

Location:
branches/session_centric/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/session_centric/src/common/connection_handlers.py

    r9560 r9567  
    15591559                        return 
    15601560                elif mtype != 'groupchat': 
    1561                         session = self.get_session(frm, thread_id, mtype) 
     1561                        session = self.get_or_create_session(frm, thread_id, mtype) 
    15621562 
    15631563                if thread_id and not session.received_thread_id: 
     
    17321732                        is_continued)) 
    17331733 
    1734         def get_session(self, jid, thread_id, type): 
     1734        def get_or_create_session(self, jid, thread_id, type): 
    17351735                '''returns an existing session between this connection and 'jid', returns a new one if none exist.''' 
    17361736                session = self.find_session(jid, thread_id, type) 
  • branches/session_centric/src/common/zeroconf/connection_handlers_zeroconf.py

    r9299 r9567  
    659659                jid  = frm 
    660660 
    661                 session = self.get_session(frm, thread_id, mtype) 
     661                session = self.get_or_create_session(frm, thread_id, mtype) 
    662662 
    663663                if thread_id and not session.received_thread_id: 
     
    795795                raise common.xmpp.NodeProcessed 
    796796 
    797         def get_session(self, jid, thread_id, type): 
     797        def get_or_create_session(self, jid, thread_id, type): 
    798798                '''returns an existing session between this connection and 'jid', returns a new one if none exist.''' 
    799799                session = self.find_session(jid, thread_id, type) 
  • branches/session_centric/src/roster_window.py

    r9560 r9567  
    5656from groupchat_control import GroupchatControl 
    5757from groupchat_control import PrivateChatControl 
     58 
     59from session import ChatControlSession 
    5860 
    5961from common import dbus_support 
     
    33913393                        if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK and \ 
    33923394                        not event.state & gtk.gdk.CONTROL_MASK: 
    3393                                 # Don't handle dubble click if we press icon of a metacontact 
     3395                                # Don't handle double click if we press icon of a metacontact 
    33943396                                iter = model.get_iter(path) 
    33953397                                if x > x_min and x < x_min + 27 and type_ == 'contact' and \ 
     
    39293931 
    39303932                if not session: 
    3931                         session = gajim.connections[account].get_session(fjid, None, 'pm') 
     3933                        session = gajim.connections[account].get_or_create_session(fjid, None, 'pm') 
    39323934 
    39333935                chat_control = PrivateChatControl(mw, gc_contact, contact, account, session) 
     
    39683970                                resource = resource) 
    39693971 
    3970                 session = gajim.connections[account].get_session(fjid, None, 'chat') 
     3972                session = gajim.connections[account].get_or_create_session(fjid, None, 'chat') 
    39713973 
    39723974                if not gajim.interface.msg_win_mgr.has_window(fjid, account): 
     
    43154317                conn = gajim.connections[account] 
    43164318 
     4319                if not session and fjid in conn.sessions: 
     4320                        sessions = filter(lambda s: isinstance(s, ChatControlSession), 
     4321                                        conn.sessions[fjid].values()) 
     4322 
     4323                        # look for an existing session with a chat control 
     4324                        for s in sessions: 
     4325                                if s.control: 
     4326                                        session = s 
     4327                                        break 
     4328 
     4329                        if not session and not len(sessions) == 0: 
     4330                                # there are no sessions with chat controls, just take the first one 
     4331                                session = sessions[0] 
     4332 
    43174333                if not session: 
    4318                         session = conn.get_session(fjid, None, 'chat') 
     4334                        # couldn't find an existing ChatControlSession, just make a new one 
     4335                        session = conn.make_new_session(fjid, None, 'chat') 
    43194336 
    43204337                if not session.control: 
     4338                        # open a new chat control 
    43214339                        session.control = self.new_chat(session, contact, account, resource=resource) 
    43224340 
     
    43374355 
    43384356        def on_row_activated(self, widget, path): 
    4339                 '''When an iter is activated (dubblick or single click if gnome is set 
    4340                 this way''' 
     4357                '''When an iter is activated (double-click or single click if gnome is 
     4358                set this way''' 
    43414359                model = self.tree.get_model() 
    43424360                account = model[path][C_ACCOUNT].decode('utf-8') 
     
    43854403                        if jid == gajim.get_jid_from_account(account): 
    43864404                                resource = c.resource 
     4405 
    43874406                        self.on_open_chat_window(widget, c, account, resource = resource, session = session) 
    43884407 
  • branches/session_centric/src/session.py

    r9560 r9567  
    1919 
    2020                self.control = None 
     21 
     22        def acknowledge_termination(self): 
     23                # the other party terminated the session. we'll keep the control around, though. 
     24                stanza_session.EncryptedStanzaSession.acknowledge_termination(self) 
     25 
     26                self.control.session = None 
    2127 
    2228        # remove events associated with this session from the queue