Author: bct
Date: 2008-02-06 06:24:07 +0100 (Wed, 06 Feb 2008)
New Revision: 9308
Modified:
branches/session_centric/src/chat_control.py
branches/session_centric/src/common/connection_handlers.py
branches/session_centric/src/message_control.py
branches/session_centric/src/notify.py
branches/session_centric/src/roster_window.py
branches/session_centric/src/session.py
Log:
post-refactor traceback fixing
Modified: branches/session_centric/src/chat_control.py
===================================================================
--- branches/session_centric/src/chat_control.py 2008-02-06 01:40:51 UTC (rev 9307)
+++ branches/session_centric/src/chat_control.py 2008-02-06 05:24:07 UTC (rev 9308)
@@ -678,7 +678,7 @@
type_ = 'printed_' + self.type_id
event = 'message_received'
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,
self.account, self.contact)
if gc_message:
@@ -1841,10 +1841,14 @@
def shutdown(self):
# destroy banner tooltip - bug #pygtk for that!
self.status_tooltip.destroy()
+
# Send 'gone' chatstate
self.send_chatstate('gone', self.contact)
self.contact.chatstate = None
self.contact.our_chatstate = None
+
+ self.session.control = None
+
# Disconnect timer callbacks
gobject.source_remove(self.possible_paused_timeout_id)
gobject.source_remove(self.possible_inactive_timeout_id)
Modified: branches/session_centric/src/common/connection_handlers.py
===================================================================
--- branches/session_centric/src/common/connection_handlers.py 2008-02-06 01:40:51 UTC (rev 9307)
+++ branches/session_centric/src/common/connection_handlers.py 2008-02-06 05:24:07 UTC (rev 9308)
@@ -1752,7 +1752,7 @@
def delete_session(self, jid, thread_id):
try:
del self.sessions[jid][thread_id]
-
+
if not self.sessions[jid]:
del self.sessions[jid]
except KeyError:
Modified: branches/session_centric/src/message_control.py
===================================================================
--- branches/session_centric/src/message_control.py 2008-02-06 01:40:51 UTC (rev 9307)
+++ branches/session_centric/src/message_control.py 2008-02-06 05:24:07 UTC (rev 9308)
@@ -145,6 +145,7 @@
jid = self.contact.jid
if not self.session:
+ print('uhoh new session')
fjid = self.contact.get_full_jid()
new_session = gajim.connections[self.account].make_new_session(fjid)
Modified: branches/session_centric/src/notify.py
===================================================================
--- branches/session_centric/src/notify.py 2008-02-06 01:40:51 UTC (rev 9307)
+++ branches/session_centric/src/notify.py 2008-02-06 05:24:07 UTC (rev 9308)
@@ -53,8 +53,7 @@
except:
USER_HAS_GROWL = False
-
-def get_show_in_roster(event, account, contact):
+def get_show_in_roster(event, account, contact, session = None):
'''Return True if this event must be shown in roster, else False'''
if event == 'gc_message_received':
return True
@@ -65,8 +64,10 @@
if gajim.config.get_per('notifications', str(num), 'roster') == 'no':
return False
if event == 'message_received':
- chat_control = helpers.get_chat_control(account, contact)
- if chat_control:
+ if session:
+ if session.control:
+ return False
+ elif helpers.get_chat_control(account, contact):
return False
return True
Modified: branches/session_centric/src/roster_window.py
===================================================================
--- branches/session_centric/src/roster_window.py 2008-02-06 01:40:51 UTC (rev 9307)
+++ branches/session_centric/src/roster_window.py 2008-02-06 05:24:07 UTC (rev 9308)
@@ -1299,8 +1299,7 @@
for result in results:
tim = time.localtime(float(result[2]))
- self.on_message(jid, result[1], tim, account, msg_type = 'chat',
- msg_id = result[0], session = session)
+ session.roster_message(jid, result[1], tim, msg_type='chat', msg_id=result[0])
def fill_contacts_and_groups_dicts(self, array, account):
'''fill gajim.contacts and gajim.groups'''
@@ -3960,12 +3959,13 @@
contact = self.add_to_not_in_the_roster(account, jid,
resource = resource)
+ session = gajim.connections[account].get_session(fjid, None, 'chat')
+
if not gajim.interface.msg_win_mgr.has_window(fjid, account):
- session = account.make_new_session(account, fjid)
- self.control = 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)):
- chat_control.read_queue()
+ session.control.read_queue()
mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
mw.set_active_tab(fjid, account)
@@ -4292,16 +4292,25 @@
fjid = contact.jid
if 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)
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)
- ctrl = win.get_control(fjid, account)
# 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)
- if gajim.connections[account].is_zeroconf and \
- gajim.connections[account].status in ('offline', 'invisible'):
+ if conn.is_zeroconf and conn.status in ('offline', 'invisible'):
win.get_control(fjid, account).got_disconnected()
win.window.present()
Modified: branches/session_centric/src/session.py
===================================================================
--- branches/session_centric/src/session.py 2008-02-06 01:40:51 UTC (rev 9307)
+++ branches/session_centric/src/session.py 2008-02-06 05:24:07 UTC (rev 9308)
@@ -51,7 +51,7 @@
contact.chatstate = chatstate
if contact.our_chatstate == 'ask': # we were jep85 disco?
contact.our_chatstate = 'active' # no more
- self.control.handle_incoming_chatstate()
+ #self.control.handle_incoming_chatstate() XXX
elif contact.chatstate != 'active':
# got no valid jep85 answer, peer does not support it
contact.chatstate = False
@@ -109,7 +109,10 @@
first, nickname, msg, focused], advanced_notif_num)
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='',
subject=None, resource='', msg_id=None, user_nick='',
@@ -188,7 +191,7 @@
type_ = 'normal'
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)
event = gajim.events.create_event(type_, (msg, subject, msg_type, tim,
@@ -199,7 +202,7 @@
if popup:
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)):
self.control.read_queue()