pm bugfix
This commit is contained in:
parent
be0af1a56b
commit
1962b231e6
5 changed files with 48 additions and 42 deletions
|
@ -1586,7 +1586,7 @@ class ChatControl(ChatControlBase):
|
||||||
elif num_unread > 1:
|
elif num_unread > 1:
|
||||||
unread = '[' + unicode(num_unread) + ']'
|
unread = '[' + unicode(num_unread) + ']'
|
||||||
|
|
||||||
# Draw tab label using chatstate
|
# Draw tab label using chatstate
|
||||||
theme = gajim.config.get('roster_theme')
|
theme = gajim.config.get('roster_theme')
|
||||||
color = None
|
color = None
|
||||||
if not chatstate:
|
if not chatstate:
|
||||||
|
@ -1846,6 +1846,7 @@ class ChatControl(ChatControlBase):
|
||||||
self.contact.chatstate = None
|
self.contact.chatstate = None
|
||||||
self.contact.our_chatstate = None
|
self.contact.our_chatstate = None
|
||||||
|
|
||||||
|
# terminate session
|
||||||
self.session.control = None
|
self.session.control = None
|
||||||
|
|
||||||
# Disconnect timer callbacks
|
# Disconnect timer callbacks
|
||||||
|
@ -2077,12 +2078,11 @@ class ChatControl(ChatControlBase):
|
||||||
# reset to status image in gc if it is a pm
|
# reset to status image in gc if it is a pm
|
||||||
# Is it a pm ?
|
# Is it a pm ?
|
||||||
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
|
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
|
||||||
# XXX fixme somehow
|
control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, self.account)
|
||||||
# control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account)
|
if control and control.type_id == message_control.TYPE_GC:
|
||||||
# if control and control.type_id == message_control.TYPE_GC:
|
control.update_ui()
|
||||||
# control.update_ui()
|
control.parent_win.show_title()
|
||||||
# control.parent_win.show_title()
|
typ = 'pm'
|
||||||
# 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')):
|
||||||
|
@ -2093,8 +2093,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
|
||||||
|
@ -2140,18 +2140,18 @@ class ChatControl(ChatControlBase):
|
||||||
window.set_app_paintable(True)
|
window.set_app_paintable(True)
|
||||||
if gtk.gtk_version >= (2, 10, 0) and gtk.pygtk_version >= (2, 10, 0):
|
if gtk.gtk_version >= (2, 10, 0) and gtk.pygtk_version >= (2, 10, 0):
|
||||||
window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP)
|
window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP)
|
||||||
|
|
||||||
window.realize()
|
window.realize()
|
||||||
window.window.set_back_pixmap(pixmap, False) # make it transparent
|
window.window.set_back_pixmap(pixmap, False) # make it transparent
|
||||||
window.window.shape_combine_mask(mask, 0, 0)
|
window.window.shape_combine_mask(mask, 0, 0)
|
||||||
|
|
||||||
# make the bigger avatar window show up centered
|
# make the bigger avatar window show up centered
|
||||||
x0, y0 = small_avatar.window.get_origin()
|
x0, y0 = small_avatar.window.get_origin()
|
||||||
x0 += small_avatar.allocation.x
|
x0 += small_avatar.allocation.x
|
||||||
y0 += small_avatar.allocation.y
|
y0 += small_avatar.allocation.y
|
||||||
center_x= x0 + (small_avatar.allocation.width / 2)
|
center_x= x0 + (small_avatar.allocation.width / 2)
|
||||||
center_y = y0 + (small_avatar.allocation.height / 2)
|
center_y = y0 + (small_avatar.allocation.height / 2)
|
||||||
pos_x, pos_y = center_x - (avatar_w / 2), center_y - (avatar_h / 2)
|
pos_x, pos_y = center_x - (avatar_w / 2), center_y - (avatar_h / 2)
|
||||||
window.move(pos_x, pos_y)
|
window.move(pos_x, pos_y)
|
||||||
# make the cursor invisible so we can see the image
|
# make the cursor invisible so we can see the image
|
||||||
invisible_cursor = gtkgui_helpers.get_invisible_cursor()
|
invisible_cursor = gtkgui_helpers.get_invisible_cursor()
|
||||||
|
|
|
@ -1924,6 +1924,7 @@ class Interface:
|
||||||
if ctrl:
|
if ctrl:
|
||||||
new_sess = gajim.connections[account].make_new_session(str(jid))
|
new_sess = gajim.connections[account].make_new_session(str(jid))
|
||||||
ctrl.set_session(new_sess)
|
ctrl.set_session(new_sess)
|
||||||
|
gajim.connections[account].delete_session(str(jid), session.thread_id)
|
||||||
|
|
||||||
if was_encrypted:
|
if was_encrypted:
|
||||||
ctrl.print_esession_details()
|
ctrl.print_esession_details()
|
||||||
|
|
|
@ -604,7 +604,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
|
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
|
||||||
|
|
||||||
# We print if window is opened
|
# We print if window is opened
|
||||||
pm_control = gajim.interface.msg_win_mgr.get_control(fjid, self.account, session)
|
pm_control = session.control
|
||||||
|
|
||||||
if pm_control:
|
if pm_control:
|
||||||
pm_control.print_conversation(msg, tim = tim, xhtml = xhtml)
|
pm_control.print_conversation(msg, tim = tim, xhtml = xhtml)
|
||||||
|
@ -632,7 +632,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.parent_win.show_title()
|
self.parent_win.show_title()
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
else:
|
else:
|
||||||
self._start_private_message(nick, session)
|
self._start_private_message(nick)
|
||||||
# Scroll to line
|
# Scroll to line
|
||||||
self.list_treeview.expand_row(path[0:1], False)
|
self.list_treeview.expand_row(path[0:1], False)
|
||||||
self.list_treeview.scroll_to_cell(path)
|
self.list_treeview.scroll_to_cell(path)
|
||||||
|
@ -891,10 +891,9 @@ class GroupchatControl(ChatControlBase):
|
||||||
nick = model[iter][C_NICK].decode('utf-8')
|
nick = model[iter][C_NICK].decode('utf-8')
|
||||||
fjid = gajim.construct_fjid(self.room_jid, nick) # 'fake' jid
|
fjid = gajim.construct_fjid(self.room_jid, nick) # 'fake' jid
|
||||||
|
|
||||||
self._start_private_message(nick)
|
ctrl = self._start_private_message(nick)
|
||||||
if msg:
|
if msg:
|
||||||
gajim.interface.msg_win_mgr.get_control(fjid, self.account).\
|
ctrl.send_message(msg)
|
||||||
send_message(msg)
|
|
||||||
|
|
||||||
def on_send_file(self, widget, gc_contact):
|
def on_send_file(self, widget, gc_contact):
|
||||||
'''sends a file to a contact in the room'''
|
'''sends a file to a contact in the room'''
|
||||||
|
@ -2041,6 +2040,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
win.set_active_tab(ctrl)
|
win.set_active_tab(ctrl)
|
||||||
win.window.present()
|
win.window.present()
|
||||||
|
|
||||||
|
return ctrl
|
||||||
|
|
||||||
def on_row_activated(self, widget, path):
|
def on_row_activated(self, widget, path):
|
||||||
'''When an iter is activated (dubblick or single click if gnome is set
|
'''When an iter is activated (dubblick or single click if gnome is set
|
||||||
this way'''
|
this way'''
|
||||||
|
@ -2099,7 +2100,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
return
|
return
|
||||||
|
|
||||||
if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK:
|
if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK:
|
||||||
self.on_row_activated(widget, path)
|
self.on_row_activated(widget, path)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
|
|
|
@ -117,25 +117,24 @@ class MessageControl:
|
||||||
return len(gajim.events.get_events(self.account, self.contact.jid))
|
return len(gajim.events.get_events(self.account, self.contact.jid))
|
||||||
|
|
||||||
def set_session(self, session):
|
def set_session(self, session):
|
||||||
if hasattr(self, 'session') and session == self.session:
|
oldsession = None
|
||||||
|
if hasattr(self, 'session'):
|
||||||
|
oldsession = self.session
|
||||||
|
|
||||||
|
if oldsession and session == oldsession:
|
||||||
return
|
return
|
||||||
|
|
||||||
was_encrypted = False
|
|
||||||
|
|
||||||
if hasattr(self, 'session') and self.session:
|
|
||||||
if self.session.enable_encryption:
|
|
||||||
was_encrypted = True
|
|
||||||
|
|
||||||
gajim.connections[self.account].delete_session(self.session.jid,
|
|
||||||
self.session.thread_id)
|
|
||||||
|
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
if session:
|
if session:
|
||||||
session.control = self
|
session.control = self
|
||||||
|
|
||||||
if was_encrypted:
|
if oldsession:
|
||||||
self.print_esession_details()
|
self.parent_win.change_thread_key(self.contact.jid,
|
||||||
|
self.account, oldsession.thread_id, session.thread_id)
|
||||||
|
|
||||||
|
if oldsession.enable_encryption:
|
||||||
|
self.print_esession_details()
|
||||||
|
|
||||||
def send_message(self, message, keyID = '', type = 'chat',
|
def send_message(self, message, keyID = '', type = 'chat',
|
||||||
chatstate = None, msg_id = None, composing_xep = None, resource = None,
|
chatstate = None, msg_id = None, composing_xep = None, resource = None,
|
||||||
|
@ -144,13 +143,6 @@ class MessageControl:
|
||||||
'''
|
'''
|
||||||
jid = self.contact.jid
|
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)
|
|
||||||
|
|
||||||
self.set_session(new_session)
|
|
||||||
|
|
||||||
# Send and update history
|
# Send and update history
|
||||||
return gajim.connections[self.account].send_message(jid, message, keyID,
|
return gajim.connections[self.account].send_message(jid, message, keyID,
|
||||||
type = type, chatstate = chatstate, msg_id = msg_id,
|
type = type, chatstate = chatstate, msg_id = msg_id,
|
||||||
|
|
|
@ -429,6 +429,7 @@ class MessageWindow(object):
|
||||||
|
|
||||||
fjid = ctrl.get_full_jid()
|
fjid = ctrl.get_full_jid()
|
||||||
thread_id = ctrl.session.thread_id
|
thread_id = ctrl.session.thread_id
|
||||||
|
|
||||||
del self._controls[ctrl.account][fjid][thread_id]
|
del self._controls[ctrl.account][fjid][thread_id]
|
||||||
|
|
||||||
if len(self._controls[ctrl.account][fjid]) == 0:
|
if len(self._controls[ctrl.account][fjid]) == 0:
|
||||||
|
@ -567,19 +568,30 @@ class MessageWindow(object):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def change_key(self, old_jid, new_jid, acct):
|
def change_key(self, old_jid, new_jid, acct):
|
||||||
'''Change the key of a control'''
|
'''Change the JID key of a control'''
|
||||||
try:
|
try:
|
||||||
# Check if control exists
|
# Check if controls exists
|
||||||
ctrl = self._controls[acct][old_jid]
|
ctrls = self._controls[acct][old_jid]
|
||||||
except:
|
except KeyError:
|
||||||
return
|
return
|
||||||
self._controls[acct][new_jid] = self._controls[acct][old_jid]
|
self._controls[acct][new_jid] = ctrls
|
||||||
del self._controls[acct][old_jid]
|
del self._controls[acct][old_jid]
|
||||||
if old_jid in gajim.last_message_time[acct]:
|
if old_jid in gajim.last_message_time[acct]:
|
||||||
gajim.last_message_time[acct][new_jid] = \
|
gajim.last_message_time[acct][new_jid] = \
|
||||||
gajim.last_message_time[acct][old_jid]
|
gajim.last_message_time[acct][old_jid]
|
||||||
del gajim.last_message_time[acct][old_jid]
|
del gajim.last_message_time[acct][old_jid]
|
||||||
|
|
||||||
|
def change_thread_key(self, jid, acct, old_thread_id, new_thread_id):
|
||||||
|
'''Change the thread_id key of a control'''
|
||||||
|
try:
|
||||||
|
# Check if control exists
|
||||||
|
ctrl = self._controls[acct][jid][old_thread_id]
|
||||||
|
except KeyError:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._controls[acct][jid][new_thread_id] = ctrl
|
||||||
|
del self._controls[acct][jid][old_thread_id]
|
||||||
|
|
||||||
def controls(self):
|
def controls(self):
|
||||||
for jid_dict in self._controls.values():
|
for jid_dict in self._controls.values():
|
||||||
for ctrl_dict in jid_dict.values():
|
for ctrl_dict in jid_dict.values():
|
||||||
|
|
Loading…
Add table
Reference in a new issue