add <thread/> to replies to single message that contain a <thread/>

This commit is contained in:
Brendan Taylor 2007-05-30 15:31:41 +00:00
parent 96e6b34cd7
commit ec37a97ed6
5 changed files with 19 additions and 12 deletions

View File

@ -839,7 +839,7 @@ class Connection(ConnectionHandlers):
def send_message(self, jid, msg, keyID, type = 'chat', subject='', def send_message(self, jid, msg, keyID, type = 'chat', subject='',
chatstate = None, msg_id = None, composing_jep = None, resource = None, chatstate = None, msg_id = None, composing_jep = None, resource = None,
user_nick = None, xhtml = None): user_nick = None, xhtml = None, thread = None):
if not self.connection: if not self.connection:
return 1 return 1
if msg and not xhtml and gajim.config.get('rst_formatting_outgoing_messages'): if msg and not xhtml and gajim.config.get('rst_formatting_outgoing_messages'):
@ -883,6 +883,10 @@ class Connection(ConnectionHandlers):
if msgenc: if msgenc:
msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc) msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc)
# XEP-0201
if thread:
msg_iq.setTag("thread").setData(thread)
# JEP-0172: user_nickname # JEP-0172: user_nickname
if user_nick: if user_nick:
msg_iq.setTag('nick', namespace = common.xmpp.NS_NICK).setData( msg_iq.setTag('nick', namespace = common.xmpp.NS_NICK).setData(

View File

@ -1407,6 +1407,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
msghtml = msg.getXHTML() msghtml = msg.getXHTML()
mtype = msg.getType() mtype = msg.getType()
subject = msg.getSubject() # if not there, it's None subject = msg.getSubject() # if not there, it's None
thread = msg.getThread()
tim = msg.getTimestamp() tim = msg.getTimestamp()
tim = time.strptime(tim, '%Y%m%dT%H:%M:%S') tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')
tim = time.localtime(timegm(tim)) tim = time.localtime(timegm(tim))
@ -1523,7 +1524,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if treat_as: if treat_as:
mtype = treat_as mtype = treat_as
self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype,
subject, chatstate, msg_id, composing_jep, user_nick, msghtml)) subject, chatstate, msg_id, composing_jep, user_nick, msghtml, thread))
# END messageCB # END messageCB
def _pubsubEventCB(self, con, msg): def _pubsubEventCB(self, con, msg):

View File

@ -1686,7 +1686,7 @@ class SingleMessageWindow:
or 'receive'. or 'receive'.
''' '''
def __init__(self, account, to = '', action = '', from_whom = '', def __init__(self, account, to = '', action = '', from_whom = '',
subject = '', message = '', resource = ''): subject = '', message = '', resource = '', thread = None):
self.account = account self.account = account
self.action = action self.action = action
@ -1695,6 +1695,7 @@ class SingleMessageWindow:
self.to = to self.to = to
self.from_whom = from_whom self.from_whom = from_whom
self.resource = resource self.resource = resource
self.thread = thread
self.xml = gtkgui_helpers.get_glade('single_message_window.glade') self.xml = gtkgui_helpers.get_glade('single_message_window.glade')
self.window = self.xml.get_widget('single_message_window') self.window = self.xml.get_widget('single_message_window')
@ -1896,7 +1897,7 @@ class SingleMessageWindow:
# FIXME: allow GPG message some day # FIXME: allow GPG message some day
gajim.connections[self.account].send_message(to_whom_jid, message, gajim.connections[self.account].send_message(to_whom_jid, message,
keyID = None, type = 'normal', subject=subject) keyID = None, type = 'normal', subject=subject, thread = self.thread)
self.subject_entry.set_text('') # we sent ok, clear the subject self.subject_entry.set_text('') # we sent ok, clear the subject
self.message_tv_buffer.set_text('') # we sent ok, clear the textview self.message_tv_buffer.set_text('') # we sent ok, clear the textview
@ -1913,7 +1914,7 @@ class SingleMessageWindow:
self.window.destroy() self.window.destroy()
SingleMessageWindow(self.account, to = self.from_whom, SingleMessageWindow(self.account, to = self.from_whom,
action = 'send', from_whom = self.from_whom, subject = self.subject, action = 'send', from_whom = self.from_whom, subject = self.subject,
message = self.message) message = self.message, thread = self.thread)
def on_send_and_close_button_clicked(self, widget): def on_send_and_close_button_clicked(self, widget):
self.send_single_message() self.send_single_message()

View File

@ -665,7 +665,7 @@ class Interface:
def handle_event_msg(self, account, array): def handle_event_msg(self, account, array):
# 'MSG' (account, (jid, msg, time, encrypted, msg_type, subject, # 'MSG' (account, (jid, msg, time, encrypted, msg_type, subject,
# chatstate, msg_id, composing_jep, user_nick, xhtml)) # chatstate, msg_id, composing_jep, user_nick, xhtml, thread))
# user_nick is JEP-0172 # user_nick is JEP-0172
full_jid_with_resource = array[0] full_jid_with_resource = array[0]
@ -680,6 +680,7 @@ class Interface:
msg_id = array[7] msg_id = array[7]
composing_jep = array[8] composing_jep = array[8]
xhtml = array[10] xhtml = array[10]
thread = array[11]
if gajim.config.get('ignore_incoming_xhtml'): if gajim.config.get('ignore_incoming_xhtml'):
xhtml = None xhtml = None
if gajim.jid_is_transport(jid): if gajim.jid_is_transport(jid):
@ -775,12 +776,12 @@ class Interface:
if encrypted: if encrypted:
self.roster.on_message(jid, message, array[2], account, array[3], self.roster.on_message(jid, message, array[2], account, array[3],
msg_type, subject, resource, msg_id, array[9], msg_type, subject, resource, msg_id, array[9],
advanced_notif_num) advanced_notif_num, thread = thread)
else: else:
# xhtml in last element # xhtml in last element
self.roster.on_message(jid, message, array[2], account, array[3], self.roster.on_message(jid, message, array[2], account, array[3],
msg_type, subject, resource, msg_id, array[9], msg_type, subject, resource, msg_id, array[9],
advanced_notif_num, xhtml = xhtml) advanced_notif_num, xhtml = xhtml, thread = thread)
nickname = gajim.get_name_from_jid(account, jid) nickname = gajim.get_name_from_jid(account, jid)
# Check and do wanted notifications # Check and do wanted notifications
msg = message msg = message

View File

@ -3531,7 +3531,7 @@ class RosterWindow:
def on_message(self, jid, msg, tim, account, encrypted = False, def on_message(self, jid, msg, tim, account, encrypted = False,
msg_type = '', subject = None, resource = '', msg_id = None, msg_type = '', subject = None, resource = '', msg_id = None,
user_nick = '', advanced_notif_num = None, xhtml = None): user_nick = '', advanced_notif_num = None, xhtml = None, thread = None):
'''when we receive a message''' '''when we receive a message'''
contact = None contact = None
# if chat window will be for specific resource # if chat window will be for specific resource
@ -3588,7 +3588,7 @@ class RosterWindow:
if msg_type == 'normal' and popup: # it's single message to be autopopuped if msg_type == 'normal' and popup: # it's single message to be autopopuped
dialogs.SingleMessageWindow(account, contact.jid, dialogs.SingleMessageWindow(account, contact.jid,
action = 'receive', from_whom = jid, subject = subject, action = 'receive', from_whom = jid, subject = subject,
message = msg, resource = resource) message = msg, resource = resource, thread = thread)
return return
# We print if window is opened and it's not a single message # We print if window is opened and it's not a single message
@ -3611,7 +3611,7 @@ class RosterWindow:
show_in_roster = notify.get_show_in_roster(event_type, account, contact) show_in_roster = notify.get_show_in_roster(event_type, account, contact)
show_in_systray = notify.get_show_in_systray(event_type, account, contact) show_in_systray = notify.get_show_in_systray(event_type, account, contact)
event = gajim.events.create_event(type_, (msg, subject, msg_type, tim, event = gajim.events.create_event(type_, (msg, subject, msg_type, tim,
encrypted, resource, msg_id, xhtml), show_in_roster = show_in_roster, encrypted, resource, msg_id, xhtml, thread), show_in_roster = show_in_roster,
show_in_systray = show_in_systray) show_in_systray = show_in_systray)
gajim.events.add_event(account, fjid, event) gajim.events.add_event(account, fjid, event)
if popup: if popup:
@ -3873,7 +3873,7 @@ class RosterWindow:
if event.type_ == 'normal': if event.type_ == 'normal':
dialogs.SingleMessageWindow(account, jid, dialogs.SingleMessageWindow(account, jid,
action = 'receive', from_whom = jid, subject = data[1], action = 'receive', from_whom = jid, subject = data[1],
message = data[0], resource = data[5]) message = data[0], resource = data[5], thread = data[8])
gajim.interface.remove_first_event(account, jid, event.type_) gajim.interface.remove_first_event(account, jid, event.type_)
return True return True
elif event.type_ == 'file-request': elif event.type_ == 'file-request':