Commit 99f2997d authored by Brendan Taylor's avatar Brendan Taylor

pm fixes

parent 20beea4b
......@@ -927,9 +927,8 @@ class ChatControlBase(MessageControl):
if contact:
gajim.interface.roster.draw_contact(room_jid, self.account)
groupchat_control.draw_contact(nick)
mw = gajim.interface.msg_win_mgr.get_gc_window(room_jid, self.account)
if mw:
mw.redraw_tab(groupchat_control)
if groupchat_control.parent_win:
groupchat_control.parent_win.redraw_tab(groupchat_control)
else:
gajim.interface.roster.draw_contact(jid, self.account)
gajim.interface.roster.show_title()
......
......@@ -1029,7 +1029,7 @@ class ConnectionVcard:
gajim.interface.remove_avatar_files(our_jid)
self.awaiting_answers[id] = (VCARD_PUBLISHED, iq2)
def _IqCB(self, con, iq_obj):
id = iq_obj.getID()
......@@ -1081,6 +1081,7 @@ class ConnectionVcard:
our_jid = gajim.get_jid_from_account(self.name)
if iq_obj.getType() == 'error' and jid == our_jid:
# our server doesn't support vcard
gajim.log.debug('xxx error xxx')
self.vcard_supported = False
if not iq_obj.getTag('vCard') or iq_obj.getType() == 'error':
if frm and frm != our_jid:
......
......@@ -727,7 +727,7 @@ class Interface:
full_jid_with_resource = array[0]
jids = full_jid_with_resource.split('/', 1)
jid = jids[0]
gc_control = self.msg_win_mgr.get_control(jid, account)
gc_control = self.msg_win_mgr.get_gc_control(jid, account)
if not gc_control and \
jid in self.minimized_controls[account]:
gc_control = self.minimized_controls[account][jid]
......
......@@ -121,7 +121,7 @@ class PrivateChatControl(ChatControl):
def __init__(self, parent_win, gc_contact, contact, account, session):
room_jid = contact.jid.split('/')[0]
room_ctrl = gajim.interface.msg_win_mgr.get_control(room_jid, account)
room_ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account)
if gajim.interface.minimized_controls[account].has_key(room_jid):
room_ctrl = gajim.interface.minimized_controls[account][room_jid]
self.room_name = room_ctrl.name
......@@ -448,9 +448,9 @@ class GroupchatControl(ChatControlBase):
'state_muc_msg_color')
if color_name:
color = gtk.gdk.colormap_get_system().alloc_color(color_name)
label_str = self.name
# count waiting highlighted messages
unread = ''
num_unread = self.get_nb_unread()
......@@ -604,9 +604,11 @@ class GroupchatControl(ChatControlBase):
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
# We print if window is opened
pm_control = gajim.interface.msg_win_mgr.get_control(fjid, self.account)
pm_control = gajim.interface.msg_win_mgr.get_control(fjid, self.account, session)
if pm_control:
pm_control.print_conversation(msg, tim = tim, xhtml = xhtml)
return
event = gajim.events.create_event('pm', (msg, '', 'incoming', tim,
......@@ -883,7 +885,7 @@ class GroupchatControl(ChatControlBase):
def on_send_pm(self, widget = None, model = None, iter = None, nick = None,
msg = None):
'''opens a chat window and msg is not None sends private message to a
'''opens a chat window and if msg is not None sends private message to a
contact in a room'''
if nick is None:
nick = model[iter][C_NICK].decode('utf-8')
......@@ -1603,7 +1605,7 @@ class GroupchatControl(ChatControlBase):
for nick in nick_list:
# Update pm chat window
fjid = self.room_jid + '/' + nick
ctrl = gajim.interface.msg_win_mgr.get_control(fjid, self.account)
ctrl = gajim.interface.msg_win_mgr.get_gc_control(fjid, self.account)
if ctrl:
contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
contact.show = 'offline'
......@@ -2033,7 +2035,10 @@ class GroupchatControl(ChatControlBase):
if not win:
gajim.interface.roster.new_private_chat(gc_c, self.account)
win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account)
win.set_active_tab(nick_jid, self.account)
ctrl = win.get_controls(nick_jid, self.account)[0]
win.set_active_tab(ctrl)
win.window.present()
def on_row_activated(self, widget, path):
......
......@@ -3927,6 +3927,9 @@ class RosterWindow:
if not mw:
mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_)
if not session:
session = gajim.connections[account].get_session(fjid, None, 'pm')
chat_control = PrivateChatControl(mw, gc_contact, contact, account, session)
mw.new_tab(chat_control)
if len(gajim.events.get_events(account, fjid)):
......
......@@ -107,19 +107,18 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if gajim.jid_is_transport(jid):
jid = jid.replace('@', '')
#groupchat_control = gajim.interface.msg_win_mgr.get_control(jid, self.conn.name)
groupchat_control = gajim.interface.msg_win_mgr.get_gc_control(jid, self.conn.name)
# XXX fixme
# if not groupchat_control and \
# jid in gajim.interface.minimized_controls[self.conn.name]:
# 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
# if groupchat_control and groupchat_control.type_id == \
# message_control.TYPE_GC:
if groupchat_control and groupchat_control.type_id == \
message_control.TYPE_GC:
# It's a Private message
# pm = True
# msg_type = 'pm'
pm = True
msg_type = 'pm'
jid_of_control = full_jid_with_resource
......@@ -134,7 +133,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
contact.chatstate = chatstate
if contact.our_chatstate == 'ask': # we were jep85 disco?
contact.our_chatstate = 'active' # no more
#self.control.handle_incoming_chatstate() XXX
self.control.handle_incoming_chatstate()
elif contact.chatstate != 'active':
# got no valid jep85 answer, peer does not support it
contact.chatstate = False
......@@ -168,8 +167,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if pm:
nickname = resource
groupchat_control.on_private_message(nickname, msgtxt, array[2],
xhtml, session, msg_id)
groupchat_control.on_private_message(nickname, msgtxt, tim,
xhtml, self, msg_id)
else:
self.roster_message(jid, msgtxt, tim, encrypted, msg_type,
subject, resource, msg_id, user_nick, advanced_notif_num,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment