correctly forward unread printed messages to other resources. Fixes #7094

This commit is contained in:
Yann Leboulanger 2012-04-01 19:39:26 +02:00
parent 6fbb0b7847
commit 794a66e435
6 changed files with 24 additions and 20 deletions

View File

@ -981,8 +981,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
show_in_systray = notify.get_show_in_systray(event,
self.account, self.contact, type_)
event = gajim.events.create_event(type_, (self, msg_id),
show_in_roster=show_in_roster,
event = gajim.events.create_event(type_, (text, subject, self,
msg_id), show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
gajim.events.add_event(self.account, full_jid, event)
# We need to redraw contact if we show in roster
@ -1649,15 +1649,15 @@ class ChatControl(ChatControlBase):
self.restore_conversation()
self.msg_textview.grab_focus()
# change tooltip text for audio and video buttons if python-farsight is
# change tooltip text for audio and video buttons if python-farstream is
# not installed
if not gajim.HAVE_FARSIGHT:
if not gajim.HAVE_FARSTREAM:
tooltip_text = self._audio_button.get_tooltip_text()
self._audio_button.set_tooltip_text(
'%s\n%s' % (tooltip_text, _('Requires python-farsight.')))
'%s\n%s' % (tooltip_text, _('Requires python-farstream.')))
tooltip_text = self._video_button.get_tooltip_text()
self._video_button.set_tooltip_text(
'%s\n%s' % (tooltip_text, _('Requires python-farsight.')))
'%s\n%s' % (tooltip_text, _('Requires python-farstream.')))
gajim.ged.register_event_handler('pep-received', ged.GUI1,
self._nec_pep_received)
@ -1705,7 +1705,7 @@ class ChatControl(ChatControlBase):
# Jingle detection
if self.contact.supports(NS_JINGLE_ICE_UDP) and \
gajim.HAVE_FARSIGHT and self.contact.resource:
gajim.HAVE_FARSTREAM and self.contact.resource:
self.audio_available = self.contact.supports(NS_JINGLE_RTP_AUDIO)
self.video_available = self.contact.supports(NS_JINGLE_RTP_VIDEO)
else:

View File

@ -56,10 +56,10 @@ class AdHocCommand:
assert status in ('executing', 'completed', 'canceled')
response = request.buildReply('result')
cmd = response.addChild('command', namespace=xmpp.NS_COMMANDS, attrs={
'sessionid': self.sessionid,
'node': self.commandnode,
'status': status})
cmd = response.getTag('command', namespace=xmpp.NS_COMMANDS)
cmd.setAttr('sessionid', self.sessionid)
cmd.setAttr('node', self.commandnode)
cmd.setAttr('status', status)
if defaultaction is not None or actions is not None:
if defaultaction is not None:
assert defaultaction in ('cancel', 'execute', 'prev', 'next',
@ -277,13 +277,17 @@ class ForwardMessagesCommand(AdHocCommand):
def execute(self, request):
account = self.connection.name
# Forward messages
events = gajim.events.get_events(account, types=['chat', 'normal'])
events = gajim.events.get_events(account, types=['chat', 'normal',
'printed_chat'])
j, resource = gajim.get_room_and_nick_from_fjid(self.jid)
for jid in events:
for event in events[jid]:
ev_typ = event.type_
if ev_typ == 'printed_chat':
ev_typ = 'chat'
self.connection.send_message(j, event.parameters[0], '',
type_=event.type_, subject=event.parameters[1],
resource=resource, forward_from=jid, delayed=event.time_)
type_=ev_typ, subject=event.parameters[1],
resource=resource, forward_from=jid, delayed=event.time_)
# Inform other client of completion
response, cmd = self.buildResponse(request, status = 'completed')

View File

@ -45,7 +45,7 @@ class Event:
where kind in error, incoming
file-*: file_props
gc_msg: None
printed_chat: control
printed_chat: [message, subject, control, msg_id]
printed_*: None
messages that are already printed in chat, but not read
gc-invitation: [room_jid, reason, password, is_continued]

View File

@ -99,7 +99,7 @@ class StanzaSession(object):
for event in gajim.events.get_events(self.conn.name, j, types=types):
# the event wasn't in this session
if (event.type_ == 'chat' and event.parameters[8] != self) or \
(event.type_ == 'printed_chat' and event.parameters[0].session != \
(event.type_ == 'printed_chat' and event.parameters[2].session != \
self):
continue

View File

@ -1560,7 +1560,7 @@ class Interface:
return
if type_ == 'printed_chat':
ctrl = event.parameters[0]
ctrl = event.parameters[2]
elif type_ == 'chat':
session = event.parameters[8]
ctrl = session.control
@ -1598,7 +1598,7 @@ class Interface:
event = gajim.events.get_first_event(account, jid, type_)
if type_ == 'printed_pm':
ctrl = event.parameters[0]
ctrl = event.parameters[2]
elif type_ == 'pm':
session = event.parameters[8]

View File

@ -1871,9 +1871,9 @@ class RosterWindow:
for ev in event_list:
if ev.type_ != 'printed_chat':
continue
if len(ev.parameters) > 1 and ev.parameters[1]:
if len(ev.parameters) > 3 and ev.parameters[3]:
# There is a msg_id
msg_ids.append(ev.parameters[1])
msg_ids.append(ev.parameters[3])
if msg_ids:
gajim.logger.set_read_messages(msg_ids)