post-refactor traceback fixing

This commit is contained in:
Brendan Taylor 2008-02-06 05:24:07 +00:00
parent 0b574d2360
commit 381ba838b9
6 changed files with 38 additions and 20 deletions

View File

@ -678,7 +678,7 @@ class ChatControlBase(MessageControl):
type_ = 'printed_' + self.type_id type_ = 'printed_' + self.type_id
event = 'message_received' event = 'message_received'
show_in_roster = notify.get_show_in_roster(event, show_in_roster = notify.get_show_in_roster(event,
self.account, self.contact) self.account, self.contact, self.session)
show_in_systray = notify.get_show_in_systray(event, show_in_systray = notify.get_show_in_systray(event,
self.account, self.contact) self.account, self.contact)
if gc_message: if gc_message:
@ -1841,10 +1841,14 @@ class ChatControl(ChatControlBase):
def shutdown(self): def shutdown(self):
# destroy banner tooltip - bug #pygtk for that! # destroy banner tooltip - bug #pygtk for that!
self.status_tooltip.destroy() self.status_tooltip.destroy()
# Send 'gone' chatstate # Send 'gone' chatstate
self.send_chatstate('gone', self.contact) self.send_chatstate('gone', self.contact)
self.contact.chatstate = None self.contact.chatstate = None
self.contact.our_chatstate = None self.contact.our_chatstate = None
self.session.control = None
# Disconnect timer callbacks # Disconnect timer callbacks
gobject.source_remove(self.possible_paused_timeout_id) gobject.source_remove(self.possible_paused_timeout_id)
gobject.source_remove(self.possible_inactive_timeout_id) gobject.source_remove(self.possible_inactive_timeout_id)

View File

@ -145,6 +145,7 @@ class MessageControl:
jid = self.contact.jid jid = self.contact.jid
if not self.session: if not self.session:
print('uhoh new session')
fjid = self.contact.get_full_jid() fjid = self.contact.get_full_jid()
new_session = gajim.connections[self.account].make_new_session(fjid) new_session = gajim.connections[self.account].make_new_session(fjid)

View File

@ -53,8 +53,7 @@ try:
except: except:
USER_HAS_GROWL = False USER_HAS_GROWL = False
def get_show_in_roster(event, account, contact, session = None):
def get_show_in_roster(event, account, contact):
'''Return True if this event must be shown in roster, else False''' '''Return True if this event must be shown in roster, else False'''
if event == 'gc_message_received': if event == 'gc_message_received':
return True return True
@ -65,8 +64,10 @@ def get_show_in_roster(event, account, contact):
if gajim.config.get_per('notifications', str(num), 'roster') == 'no': if gajim.config.get_per('notifications', str(num), 'roster') == 'no':
return False return False
if event == 'message_received': if event == 'message_received':
chat_control = helpers.get_chat_control(account, contact) if session:
if chat_control: if session.control:
return False
elif helpers.get_chat_control(account, contact):
return False return False
return True return True

View File

@ -1299,8 +1299,7 @@ class RosterWindow:
for result in results: for result in results:
tim = time.localtime(float(result[2])) tim = time.localtime(float(result[2]))
self.on_message(jid, result[1], tim, account, msg_type = 'chat', session.roster_message(jid, result[1], tim, msg_type='chat', msg_id=result[0])
msg_id = result[0], session = session)
def fill_contacts_and_groups_dicts(self, array, account): def fill_contacts_and_groups_dicts(self, array, account):
'''fill gajim.contacts and gajim.groups''' '''fill gajim.contacts and gajim.groups'''
@ -3960,12 +3959,13 @@ class RosterWindow:
contact = self.add_to_not_in_the_roster(account, jid, contact = self.add_to_not_in_the_roster(account, jid,
resource = resource) resource = resource)
session = gajim.connections[account].get_session(fjid, None, 'chat')
if not gajim.interface.msg_win_mgr.has_window(fjid, account): if not gajim.interface.msg_win_mgr.has_window(fjid, account):
session = account.make_new_session(account, fjid) session.control = self.new_chat(session, contact, account, resource = resource)
self.control = self.new_chat(session, contact, account, resource = resource)
if len(gajim.events.get_events(account, fjid)): if len(gajim.events.get_events(account, fjid)):
chat_control.read_queue() session.control.read_queue()
mw = gajim.interface.msg_win_mgr.get_window(fjid, account) mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
mw.set_active_tab(fjid, account) mw.set_active_tab(fjid, account)
@ -4292,16 +4292,25 @@ class RosterWindow:
fjid = contact.jid fjid = contact.jid
if resource: if resource:
fjid += '/' + resource fjid += '/' + resource
conn = gajim.connections[account]
if not session:
session = conn.get_session(fjid, None, 'chat')
win = gajim.interface.msg_win_mgr.get_window(fjid, account) win = gajim.interface.msg_win_mgr.get_window(fjid, account)
if not win: if not win:
self.new_chat(session, contact, account, resource = resource) session.control = self.new_chat(session, contact, account, resource=resource)
if len(gajim.events.get_events(account, fjid)):
session.control.read_queue()
win = gajim.interface.msg_win_mgr.get_window(fjid, account) win = gajim.interface.msg_win_mgr.get_window(fjid, account)
ctrl = win.get_control(fjid, account)
# last message is long time ago # last message is long time ago
gajim.last_message_time[account][ctrl.get_full_jid()] = 0 gajim.last_message_time[account][session.control.get_full_jid()] = 0
win.set_active_tab(fjid, account) win.set_active_tab(fjid, account)
if gajim.connections[account].is_zeroconf and \ if conn.is_zeroconf and conn.status in ('offline', 'invisible'):
gajim.connections[account].status in ('offline', 'invisible'):
win.get_control(fjid, account).got_disconnected() win.get_control(fjid, account).got_disconnected()
win.window.present() win.window.present()

View File

@ -51,7 +51,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
contact.chatstate = chatstate contact.chatstate = chatstate
if contact.our_chatstate == 'ask': # we were jep85 disco? if contact.our_chatstate == 'ask': # we were jep85 disco?
contact.our_chatstate = 'active' # no more contact.our_chatstate = 'active' # no more
self.control.handle_incoming_chatstate() #self.control.handle_incoming_chatstate() XXX
elif contact.chatstate != 'active': elif contact.chatstate != 'active':
# got no valid jep85 answer, peer does not support it # got no valid jep85 answer, peer does not support it
contact.chatstate = False contact.chatstate = False
@ -109,7 +109,10 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
first, nickname, msg, focused], advanced_notif_num) first, nickname, msg, focused], advanced_notif_num)
if gajim.interface.remote_ctrl: if gajim.interface.remote_ctrl:
gajim.interface.remote_ctrl.raise_signal('NewMessage', (self.conn.name, [full_jid_with_resource, message, tim, encrypted, msg_type, subject, chatstate, msg_id, composing_xep, user_nick, xhtml, form_node])) gajim.interface.remote_ctrl.raise_signal('NewMessage',
(self.conn.name, [full_jid_with_resource, message, tim,
encrypted, msg_type, subject, chatstate, msg_id,
composing_xep, user_nick, xhtml, form_node]))
def roster_message(self, jid, msg, tim, encrypted=False, msg_type='', def roster_message(self, jid, msg, tim, encrypted=False, msg_type='',
subject=None, resource='', msg_id=None, user_nick='', subject=None, resource='', msg_id=None, user_nick='',
@ -188,7 +191,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
type_ = 'normal' type_ = 'normal'
event_type = 'single_message_received' event_type = 'single_message_received'
show_in_roster = notify.get_show_in_roster(event_type, self.conn.name, contact) show_in_roster = notify.get_show_in_roster(event_type, self.conn.name, contact, self)
show_in_systray = notify.get_show_in_systray(event_type, self.conn.name, contact) show_in_systray = notify.get_show_in_systray(event_type, self.conn.name, contact)
event = gajim.events.create_event(type_, (msg, subject, msg_type, tim, event = gajim.events.create_event(type_, (msg, subject, msg_type, tim,
@ -199,7 +202,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if popup: if popup:
if not self.control: if not self.control:
self.control = self.new_chat(self, contact, self.conn.name, resource=resource_for_chat) self.control = gajim.interface.roster.new_chat(self, contact, self.conn.name, resource=resource_for_chat)
if len(gajim.events.get_events(self.conn.name, fjid)): if len(gajim.events.get_events(self.conn.name, fjid)):
self.control.read_queue() self.control.read_queue()