multiple chat session windows per contact. groupchat and pms broken.
This commit is contained in:
parent
2648aa4a9f
commit
d4a766963f
|
@ -709,11 +709,10 @@ class ChatControlBase(MessageControl):
|
||||||
not self.parent_win.is_active() or not end) and \
|
not self.parent_win.is_active() or not end) and \
|
||||||
kind in ('incoming', 'incoming_queue'):
|
kind in ('incoming', 'incoming_queue'):
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account)
|
|
||||||
if not self.parent_win.is_active():
|
if not self.parent_win.is_active():
|
||||||
self.parent_win.show_title(True, ctrl) # Enabled Urgent hint
|
self.parent_win.show_title(True, self) # Enabled Urgent hint
|
||||||
else:
|
else:
|
||||||
self.parent_win.show_title(False, ctrl) # Disabled Urgent hint
|
self.parent_win.show_title(False, self) # Disabled Urgent hint
|
||||||
|
|
||||||
def toggle_emoticons(self):
|
def toggle_emoticons(self):
|
||||||
'''hide show emoticons_button and make sure emoticons_menu is always there
|
'''hide show emoticons_button and make sure emoticons_menu is always there
|
||||||
|
@ -905,8 +904,7 @@ class ChatControlBase(MessageControl):
|
||||||
self.parent_win.get_active_control() == self and \
|
self.parent_win.get_active_control() == self and \
|
||||||
self.parent_win.window.is_active():
|
self.parent_win.window.is_active():
|
||||||
# we are at the end
|
# we are at the end
|
||||||
if not gajim.events.remove_events(self.account, self.get_full_jid(),
|
if not self.session.remove_events(['printed_' + type_, type_]):
|
||||||
types = ['printed_' + type_, type_]):
|
|
||||||
# There were events to remove
|
# There were events to remove
|
||||||
self.redraw_after_event_removed(jid)
|
self.redraw_after_event_removed(jid)
|
||||||
|
|
||||||
|
@ -2052,12 +2050,6 @@ class ChatControl(ChatControlBase):
|
||||||
if hasattr(self, 'session') and self.session and self.session.enable_encryption:
|
if hasattr(self, 'session') and self.session and self.session.enable_encryption:
|
||||||
self.print_esession_details()
|
self.print_esession_details()
|
||||||
|
|
||||||
# Is it a pm ?
|
|
||||||
is_pm = False
|
|
||||||
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
|
|
||||||
control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account)
|
|
||||||
if control and control.type_id == message_control.TYPE_GC:
|
|
||||||
is_pm = True
|
|
||||||
# list of message ids which should be marked as read
|
# list of message ids which should be marked as read
|
||||||
message_ids = []
|
message_ids = []
|
||||||
for event in events:
|
for event in events:
|
||||||
|
@ -2082,11 +2074,16 @@ class ChatControl(ChatControlBase):
|
||||||
types = [self.type_id])
|
types = [self.type_id])
|
||||||
|
|
||||||
typ = 'chat' # Is it a normal chat or a pm ?
|
typ = 'chat' # Is it a normal chat or a pm ?
|
||||||
|
|
||||||
# reset to status image in gc if it is a pm
|
# reset to status image in gc if it is a pm
|
||||||
if is_pm:
|
# Is it a pm ?
|
||||||
control.update_ui()
|
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
|
||||||
control.parent_win.show_title()
|
# XXX fixme somehow
|
||||||
typ = 'pm'
|
# control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account)
|
||||||
|
# if control and control.type_id == message_control.TYPE_GC:
|
||||||
|
# control.update_ui()
|
||||||
|
# control.parent_win.show_title()
|
||||||
|
# typ = 'pm'
|
||||||
|
|
||||||
self.redraw_after_event_removed(jid)
|
self.redraw_after_event_removed(jid)
|
||||||
if (self.contact.show in ('offline', 'error')):
|
if (self.contact.show in ('offline', 'error')):
|
||||||
|
@ -2097,8 +2094,8 @@ class ChatControl(ChatControlBase):
|
||||||
len(gajim.contacts.get_contacts(self.account, jid)) < 2):
|
len(gajim.contacts.get_contacts(self.account, jid)) < 2):
|
||||||
gajim.interface.roster.really_remove_contact(self.contact,
|
gajim.interface.roster.really_remove_contact(self.contact,
|
||||||
self.account)
|
self.account)
|
||||||
elif typ == 'pm':
|
# elif typ == 'pm':
|
||||||
control.remove_contact(nick)
|
# control.remove_contact(nick)
|
||||||
|
|
||||||
def show_bigger_avatar(self, small_avatar):
|
def show_bigger_avatar(self, small_avatar):
|
||||||
'''resizes the avatar, if needed, so it has at max half the screen size
|
'''resizes the avatar, if needed, so it has at max half the screen size
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Events:
|
||||||
|
|
||||||
def remove_events(self, account, jid, event = None, types = []):
|
def remove_events(self, account, jid, event = None, types = []):
|
||||||
'''if event is not specified, remove all events from this jid,
|
'''if event is not specified, remove all events from this jid,
|
||||||
optionnaly only from given type
|
optionally only from given type
|
||||||
return True if no such event found'''
|
return True if no such event found'''
|
||||||
if not self._events.has_key(account):
|
if not self._events.has_key(account):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -152,8 +152,9 @@ class MessageWindow(object):
|
||||||
|
|
||||||
def get_num_controls(self):
|
def get_num_controls(self):
|
||||||
n = 0
|
n = 0
|
||||||
for dict in self._controls.values():
|
for jid_dict in self._controls.values():
|
||||||
n += len(dict)
|
for dict in jid_dict.values():
|
||||||
|
n += len(dict)
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def resize(self, width, height):
|
def resize(self, width, height):
|
||||||
|
@ -206,7 +207,11 @@ class MessageWindow(object):
|
||||||
if not self._controls.has_key(control.account):
|
if not self._controls.has_key(control.account):
|
||||||
self._controls[control.account] = {}
|
self._controls[control.account] = {}
|
||||||
fjid = control.get_full_jid()
|
fjid = control.get_full_jid()
|
||||||
self._controls[control.account][fjid] = control
|
|
||||||
|
if not self._controls[control.account].has_key(fjid):
|
||||||
|
self._controls[control.account][fjid] = {}
|
||||||
|
|
||||||
|
self._controls[control.account][fjid][control.session.thread_id] = control
|
||||||
|
|
||||||
if self.get_num_controls() == 2:
|
if self.get_num_controls() == 2:
|
||||||
# is first conversation_textview scrolled down ?
|
# is first conversation_textview scrolled down ?
|
||||||
|
@ -391,8 +396,8 @@ class MessageWindow(object):
|
||||||
else:
|
else:
|
||||||
gtkgui_helpers.set_unset_urgency_hint(self.window, False)
|
gtkgui_helpers.set_unset_urgency_hint(self.window, False)
|
||||||
|
|
||||||
def set_active_tab(self, jid, acct):
|
def set_active_tab(self, session):
|
||||||
ctrl = self._controls[acct][jid]
|
ctrl = self._controls[session.conn.name][session.jid][session.thread_id]
|
||||||
ctrl_page = self.notebook.page_num(ctrl.widget)
|
ctrl_page = self.notebook.page_num(ctrl.widget)
|
||||||
self.notebook.set_current_page(ctrl_page)
|
self.notebook.set_current_page(ctrl_page)
|
||||||
|
|
||||||
|
@ -424,7 +429,12 @@ class MessageWindow(object):
|
||||||
self.notebook.remove_page(self.notebook.page_num(ctrl.widget))
|
self.notebook.remove_page(self.notebook.page_num(ctrl.widget))
|
||||||
|
|
||||||
fjid = ctrl.get_full_jid()
|
fjid = ctrl.get_full_jid()
|
||||||
del self._controls[ctrl.account][fjid]
|
thread_id = ctrl.session.thread_id
|
||||||
|
del self._controls[ctrl.account][fjid][thread_id]
|
||||||
|
|
||||||
|
if len(self._controls[ctrl.account][fjid]) == 0:
|
||||||
|
del self._controls[ctrl.account][fjid]
|
||||||
|
|
||||||
if len(self._controls[ctrl.account]) == 0:
|
if len(self._controls[ctrl.account]) == 0:
|
||||||
del self._controls[ctrl.account]
|
del self._controls[ctrl.account]
|
||||||
|
|
||||||
|
@ -563,9 +573,10 @@ class MessageWindow(object):
|
||||||
del gajim.last_message_time[acct][old_jid]
|
del gajim.last_message_time[acct][old_jid]
|
||||||
|
|
||||||
def controls(self):
|
def controls(self):
|
||||||
for ctrl_dict in self._controls.values():
|
for jid_dict in self._controls.values():
|
||||||
for ctrl in ctrl_dict.values():
|
for ctrl_dict in jid_dict.values():
|
||||||
yield ctrl
|
for ctrl in ctrl_dict.values():
|
||||||
|
yield ctrl
|
||||||
|
|
||||||
def move_to_next_unread_tab(self, forward):
|
def move_to_next_unread_tab(self, forward):
|
||||||
ind = self.notebook.get_current_page()
|
ind = self.notebook.get_current_page()
|
||||||
|
|
|
@ -4312,18 +4312,18 @@ class RosterWindow:
|
||||||
if not session:
|
if not session:
|
||||||
session = conn.get_session(fjid, None, 'chat')
|
session = conn.get_session(fjid, None, 'chat')
|
||||||
|
|
||||||
win = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
if not session.control:
|
||||||
if not win:
|
|
||||||
session.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)):
|
if len(gajim.events.get_events(account, fjid)):
|
||||||
session.control.read_queue()
|
session.control.read_queue()
|
||||||
|
|
||||||
win = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
|
||||||
# last message is long time ago
|
# last message is long time ago
|
||||||
gajim.last_message_time[account][session.control.get_full_jid()] = 0
|
gajim.last_message_time[account][session.control.get_full_jid()] = 0
|
||||||
|
|
||||||
win.set_active_tab(fjid, account)
|
win = session.control.parent_win
|
||||||
|
win.set_active_tab(session)
|
||||||
|
|
||||||
if conn.is_zeroconf and conn.status in ('offline', 'invisible'):
|
if conn.is_zeroconf and conn.status in ('offline', 'invisible'):
|
||||||
win.get_control(fjid, account).got_disconnected()
|
win.get_control(fjid, account).got_disconnected()
|
||||||
|
|
||||||
|
@ -5204,6 +5204,7 @@ class RosterWindow:
|
||||||
start = '[' + str(nb_unread) + '] '
|
start = '[' + str(nb_unread) + '] '
|
||||||
elif nb_unread == 1:
|
elif nb_unread == 1:
|
||||||
start = '* '
|
start = '* '
|
||||||
|
|
||||||
self.window.set_title(start + 'Gajim')
|
self.window.set_title(start + 'Gajim')
|
||||||
|
|
||||||
gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread)
|
gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread)
|
||||||
|
|
|
@ -19,6 +19,21 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
|
|
||||||
self.control = None
|
self.control = None
|
||||||
|
|
||||||
|
# remove events associated with this session from the queue
|
||||||
|
def remove_events(self, types):
|
||||||
|
any_removed = False
|
||||||
|
|
||||||
|
for event in gajim.events.get_events(self.conn, self.jid, types=types):
|
||||||
|
if event.parameters[8] != self:
|
||||||
|
continue
|
||||||
|
|
||||||
|
r = gajim.events.remove_events(self.conn, self.jid, event)
|
||||||
|
|
||||||
|
if not_any_removed:
|
||||||
|
any_removed = r
|
||||||
|
|
||||||
|
return any_removed
|
||||||
|
|
||||||
# extracts chatstate from a <message/> stanza
|
# extracts chatstate from a <message/> stanza
|
||||||
def get_chatstate(self, msg, msgtxt):
|
def get_chatstate(self, msg, msgtxt):
|
||||||
composing_xep = None
|
composing_xep = None
|
||||||
|
@ -93,16 +108,18 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
jid = jid.replace('@', '')
|
jid = jid.replace('@', '')
|
||||||
|
|
||||||
groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name)
|
groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name)
|
||||||
if not groupchat_control and \
|
|
||||||
jid in gajim.interface.minimized_controls[self.conn.name]:
|
# XXX fixme
|
||||||
groupchat_control = self.minimized_controls[self.conn.name][jid]
|
# if not groupchat_control and \
|
||||||
|
# jid in gajim.interface.minimized_controls[self.conn.name]:
|
||||||
|
# groupchat_control = self.minimized_controls[self.conn.name][jid]
|
||||||
|
|
||||||
pm = False
|
pm = False
|
||||||
if groupchat_control and groupchat_control.type_id == \
|
# if groupchat_control and groupchat_control.type_id == \
|
||||||
message_control.TYPE_GC:
|
# message_control.TYPE_GC:
|
||||||
# It's a Private message
|
# It's a Private message
|
||||||
pm = True
|
# pm = True
|
||||||
msg_type = 'pm'
|
# msg_type = 'pm'
|
||||||
|
|
||||||
jid_of_control = full_jid_with_resource
|
jid_of_control = full_jid_with_resource
|
||||||
|
|
||||||
|
@ -184,6 +201,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
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='',
|
||||||
advanced_notif_num=None, xhtml=None, form_node=None):
|
advanced_notif_num=None, xhtml=None, form_node=None):
|
||||||
|
|
||||||
contact = None
|
contact = None
|
||||||
# if chat window will be for specific resource
|
# if chat window will be for specific resource
|
||||||
resource_for_chat = resource
|
resource_for_chat = resource
|
||||||
|
|
Loading…
Reference in New Issue