pending events are now in objects rather that storing parameters in tuple

This commit is contained in:
Yann Leboulanger 2016-02-29 21:04:08 +01:00
parent fbdb7656af
commit 0530308a99
9 changed files with 245 additions and 133 deletions

View File

@ -46,6 +46,7 @@ import history_window
import notify
import re
from common import events
from common import gajim
from common import helpers
from common import exceptions
@ -912,20 +913,23 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
# other_tags_for_text == ['marked'] --> highlighted gc message
if gc_message:
if 'marked' in other_tags_for_text:
type_ = 'printed_marked_gc_msg'
event_type = events.PrintedMarkedGcMsgEvent
else:
type_ = 'printed_gc_msg'
event_type = events.PrintedGcMsgEvent
event = 'gc_message_received'
else:
type_ = 'printed_' + self.type_id
if self.type_id == message_control.TYPE_CHAT:
event_type = events.PrintedChatEvent
else:
event_type = events.PrintedPmEvent
event = 'message_received'
show_in_roster = notify.get_show_in_roster(event,
self.account, self.contact, self.session)
show_in_systray = notify.get_show_in_systray(event,
self.account, self.contact, type_)
self.account, self.contact, event_type.type_)
event = gajim.events.create_event(type_, (text, subject, self,
msg_log_id), show_in_roster=show_in_roster,
event = event_type(text, subject, self, msg_log_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
@ -2677,7 +2681,7 @@ class ChatControl(ChatControlBase):
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
account=self.account, jid=self.contact.jid, chatstate=state,
msg_id=contact.msg_id, control=self))
msg_id=contact.msg_log_id, control=self))
contact.our_chatstate = state
if state == 'active':
@ -3010,23 +3014,20 @@ class ChatControl(ChatControlBase):
for event in events:
if event.type_ != self.type_id:
continue
data = event.parameters
kind = data[2]
if kind == 'error':
if event.kind == 'error':
kind = 'info'
else:
kind = 'print_queue'
if data[11]:
if event.sent_forwarded:
kind = 'out'
dm = data[10]
self.print_conversation(data[0], kind, tim=data[3],
encrypted=data[4], subject=data[1], xhtml=data[7],
displaymarking=dm)
if len(data) > 6 and isinstance(data[6], int):
message_ids.append(data[6])
self.print_conversation(event.message, kind, tim=event.time,
encrypted=event.encrypted, subject=event.subject,
xhtml=event.xhtml, displaymarking=event.displaymarking)
if isinstance(event.msg_log_id, int):
message_ids.append(event.msg_log_id)
if len(data) > 8 and not self.session:
self.set_session(data[8])
if event.session and not self.session:
self.set_session(event.session)
if message_ids:
gajim.logger.set_read_messages(message_ids)
gajim.events.remove_events(self.account, jid_with_resource,
@ -3258,7 +3259,7 @@ class ChatControl(ChatControlBase):
def _get_file_props_event(self, file_props, type_):
evs = gajim.events.get_events(self.account, self.contact.jid, [type_])
for ev in evs:
if ev.parameters == file_props:
if ev.file_props == file_props:
return ev
return None
@ -3322,15 +3323,13 @@ class ChatControl(ChatControlBase):
self._add_info_bar_message(markup, [b], file_props, Gtk.MessageType.ERROR)
def _on_accept_gc_invitation(self, widget, event):
room_jid = event.parameters[0]
password = event.parameters[2]
is_continued = event.parameters[3]
try:
if is_continued:
gajim.interface.join_gc_room(self.account, room_jid,
gajim.nicks[self.account], password, is_continued=True)
if event.is_continued:
gajim.interface.join_gc_room(self.account, event.room_jid,
gajim.nicks[self.account], event.password,
is_continued=True)
else:
dialogs.JoinGroupchatWindow(self.account, room_jid)
dialogs.JoinGroupchatWindow(self.account, event.room_jid)
except GajimGeneralException:
pass
gajim.events.remove_events(self.account, self.contact.jid, event=event)
@ -3339,17 +3338,15 @@ class ChatControl(ChatControlBase):
gajim.events.remove_events(self.account, self.contact.jid, event=event)
def _get_gc_invitation(self, event):
room_jid = event.parameters[0]
comment = event.parameters[1]
markup = '<b>%s:</b> %s' % (_('Groupchat Invitation'), room_jid)
if comment:
markup += ' (%s)' % comment
markup = '<b>%s:</b> %s' % (_('Groupchat Invitation'), event.room_jid)
if event.comment:
markup += ' (%s)' % event.comment
b1 = Gtk.Button(_('_Join'))
b1.connect('clicked', self._on_accept_gc_invitation, event)
b2 = Gtk.Button(stock=Gtk.STOCK_CANCEL)
b2.connect('clicked', self._on_cancel_gc_invitation, event)
self._add_info_bar_message(markup, [b1, b2], event.parameters,
Gtk.MessageType.QUESTION)
self._add_info_bar_message(markup, [b1, b2], (event.room_jid,
event.comment), Gtk.MessageType.QUESTION)
def on_event_added(self, event):
if event.account != self.account:
@ -3357,19 +3354,19 @@ class ChatControl(ChatControlBase):
if event.jid != self.contact.jid:
return
if event.type_ == 'file-request':
self._got_file_request(event.parameters)
self._got_file_request(event.file_props)
elif event.type_ == 'file-completed':
self._got_file_completed(event.parameters)
self._got_file_completed(event.file_props)
elif event.type_ in ('file-error', 'file-stopped'):
msg_err = ''
if event.parameters.error == -1:
if event.file_props.error == -1:
msg_err = _('Remote contact stopped transfer')
elif event.parameters.error == -6:
elif event.file_props.error == -6:
msg_err = _('Error opening file')
self._got_file_error(event.parameters, event.type_,
self._got_file_error(event.file_props, event.type_,
_('File transfer stopped'), msg_err)
elif event.type_ in ('file-request-error', 'file-send-error'):
self._got_file_error(event.parameters, event.type_,
self._got_file_error(event.file_props, event.type_,
_('File transfer cancelled'),
_('Connection with peer cannot be established.'))
elif event.type_ == 'gc-invitation':
@ -3392,11 +3389,11 @@ class ChatControl(ChatControlBase):
removed = False
for ib_msg in self.info_bar_queue:
if ev.type_ == 'gc-invitation':
if ev.parameters[0] == ib_msg[2][0]:
if ev.room_jid == ib_msg[2][0]:
self.info_bar_queue.remove(ib_msg)
removed = True
else: # file-*
if ib_msg[2] == ev.parameters:
if ib_msg[2] == ev.file_props:
self.info_bar_queue.remove(ib_msg)
removed = True
if removed:

View File

@ -287,9 +287,9 @@ class ForwardMessagesCommand(AdHocCommand):
if ev_typ == 'printed_chat':
ev_typ = 'chat'
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
account=account, jid=j, message=event.parameters[0],
type_=ev_typ, subject=event.parameters[1],
resource=resource, forward_from=jid, delayed=event.time_))
account=account, jid=j, message=event.message, type_=ev_typ,
subject=event.subject, resource=resource, forward_from=jid,
delayed=event.time_))
# Inform other client of completion
response, cmd = self.buildResponse(request, status = 'completed')
@ -321,10 +321,9 @@ class FwdMsgThenDisconnectCommand(AdHocCommand):
if ev_typ == 'printed_chat':
ev_typ = 'chat'
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
account=account, jid=j, message=event.parameters[0],
type_=ev_typ, subject=event.parameters[1],
resource=resource, forward_from=jid, delayed=event.time_,
now=True))
account=account, jid=j, message=event.message, type_=ev_typ,
subject=event.subject, resource=resource, forward_from=jid,
delayed=event.time_, now=True))
response, cmd = self.buildResponse(request, status = 'completed')
cmd.addChild('note', {}, _('The status has been changed.'))

View File

@ -31,8 +31,7 @@ class Event:
Information concerning each event
"""
def __init__(self, type_, time_, parameters, show_in_roster=False,
show_in_systray=True):
def __init__(self, time_=None, show_in_roster=False, show_in_systray=True):
"""
type_ in chat, normal, file-request, file-error, file-completed,
file-request-error, file-send-error, file-stopped, gc_msg, pm,
@ -41,27 +40,138 @@ class Event:
parameters is (per type_):
chat, normal, pm: [message, subject, kind, time, encrypted, resource,
msg_id]
msg_log_id]
where kind in error, incoming
file-*: file_props
gc_msg: None
printed_chat: [message, subject, control, msg_id]
printed_chat: [message, subject, control, msg_log_id]
printed_*: None
messages that are already printed in chat, but not read
gc-invitation: [room_jid, reason, password, is_continued]
gc-invitation: [room_jid, reason, password, is_continued, jid_from]
subscription_request: [text, nick]
unsubscribed: contact
jingle-incoming: (fulljid, sessionid, content_types)
"""
self.type_ = type_
if time_:
self.time_ = time_
self.parameters = parameters
else:
self.time_ = time.time()
self.show_in_roster = show_in_roster
self.show_in_systray = show_in_systray
# Set when adding the event
self.jid = None
self.account = None
class ChatEvent(Event):
type_ = 'chat'
def __init__ (self, message, subject, kind, time, encrypted, resource,
msg_log_id=None, xhtml=None, session=None, form_node=None, displaymarking=None,
sent_forwarded=False, time_=None, show_in_roster=False,
show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.message = message
self.subject = subject
self.kind = kind
self.time = time
self.encrypted = encrypted
self.resource = resource
self.msg_log_id = msg_log_id
self.xhtml = xhtml
self.session = session
self.form_node = form_node
self.displaymarking = displaymarking
self.sent_forwarded = sent_forwarded
class NormalEvent(ChatEvent):
type_ = 'normal'
class PmEvent(ChatEvent):
type_ = 'pm'
class PrintedChatEvent(Event):
type_ = 'printed_chat'
def __init__(self, message, subject, control, msg_log_id, time_=None,
show_in_roster=False, show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.message = message
self.subject = subject
self.control = control
self.msg_log_id = msg_log_id
class PrintedGcMsgEvent(PrintedChatEvent):
type_ = 'printed_gc_msg'
class PrintedMarkedGcMsgEvent(PrintedChatEvent):
type_ = 'printed_marked_gc_msg'
class PrintedPmEvent(PrintedChatEvent):
type_ = 'printed_pm'
class SubscriptionRequestEvent(Event):
type_ = 'subscription_request'
def __init__(self, text, nick, time_=None, show_in_roster=False,
show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.text = text
self.nick = nick
class UnsubscribedEvent(Event):
type_ = 'unsubscribed'
def __init__(self, contact, time_=None, show_in_roster=False,
show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.contact = contact
class GcInvitationtEvent(Event):
type_ = 'gc-invitation'
def __init__(self, room_jid, reason, password, is_continued, from_jid,
time_=None, show_in_roster=False, show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.room_jid = room_jid
self.reason = reason
self.password = password
self.is_continued = is_continued
self.from_jid = from_jid
class FileRequestEvent(Event):
type_ = 'file-request'
def __init__(self, file_props, time_=None, show_in_roster=False, show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.file_props = file_props
class FileSendErrorEvent(FileRequestEvent):
type_ = 'file-send-error'
class FileErrorEvent(FileRequestEvent):
type_ = 'file-error'
class FileRequestErrorEvent(FileRequestEvent):
type_ = 'file-request-error'
class FileCompletedEvent(FileRequestEvent):
type_ = 'file-completed'
class FileStoppedEvent(FileRequestEvent):
type_ = 'file-stopped'
class FileHashErrorEvent(Event):
type_ = 'file-hash-rror'
class JingleIncomingEvent(Event):
type_ = 'jingle-incoming'
def __init__(self, peerjid, sid, content_types, time_=None, show_in_roster=False, show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.peerjid = peerjid
self.sid = sid
self.content_types = content_types
class Events:
"""
Information concerning all events
@ -122,13 +232,6 @@ class Events:
def remove_account(self, account):
del self._events[account]
def create_event(self, type_, parameters, time_=None,
show_in_roster=False, show_in_systray=True):
if not time_:
time_ = time.time()
return Event(type_, time_, parameters, show_in_roster,
show_in_systray)
def add_event(self, account, jid, event):
# No such account before ?
if account not in self._events:

View File

@ -96,8 +96,8 @@ class StanzaSession(object):
for j in (self.jid, self.jid.getStripped()):
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[2].session != \
if (event.type_ == 'chat' and event.session != self) or \
(event.type_ == 'printed_chat' and event.control.session != \
self):
continue

View File

@ -592,7 +592,7 @@ class FileTransfersWindow:
for ev_type in ('file-error', 'file-completed', 'file-request-error',
'file-send-error', 'file-stopped'):
for event in gajim.events.get_events(account, jid, [ev_type]):
if event.parameters.sid == file_props.sid:
if event.file_props.sid == file_props.sid:
gajim.events.remove_events(account, jid, event)
gajim.interface.roster.draw_contact(jid, account)
gajim.interface.roster.show_title()

View File

@ -46,6 +46,7 @@ import cell_renderer_image
import dataforms_widget
import nbxmpp
from common import events
from common import gajim
from common import helpers
from common import dataforms
@ -1082,8 +1083,9 @@ class GroupchatControl(ChatControlBase):
fjid = self.room_jid + '/' + nick
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
event = gajim.events.create_event('pm', (msg, '', 'incoming', tim,
encrypted, '', msg_log_id, xhtml, session, None, displaymarking, False))
event = events.PmEvent(msg, '', 'incoming', tim, encrypted, '',
msg_log_id, xhtml=xhtml, session=session, form_node=None,
displaymarking=displaymarking, sent_forwarded=False)
gajim.events.add_event(self.account, fjid, event)
autopopup = gajim.config.get('autopopup')

View File

@ -47,6 +47,7 @@ from gi.repository import GLib
from common import i18n
from common import gajim
from common import events
from common import dbus_support
if dbus_support.supported:
@ -468,8 +469,8 @@ class Interface:
obj.user_nick)
return
self.add_event(account, obj.jid, 'subscription_request', (obj.status,
obj.user_nick))
event = events.SubscriptionRequestEvent(obj.status, obj.user_nick)
self.add_event(account, obj.jid, event)
if helpers.allow_showing_notification(account):
path = gtkgui_helpers.get_icon_path('gajim-subscription_request',
@ -526,7 +527,8 @@ class Interface:
self.show_unsubscribed_dialog(account, contact)
return
self.add_event(account, obj.jid, 'unsubscribed', contact)
event = events.UnsubscribedEvent(contact)
self.add_event(account, obj.jid, event)
if helpers.allow_showing_notification(account):
path = gtkgui_helpers.get_icon_path('gajim-unsubscribed', 48)
@ -645,8 +647,9 @@ class Interface:
is_continued=obj.is_continued)
return
self.add_event(account, obj.jid_from, 'gc-invitation', (obj.room_jid,
obj.reason, obj.password, obj.is_continued, obj.jid_from))
event = events.GcInvitationtEvent(obj.room_jid, obj.reason,
obj.password, obj.is_continued, obj.jid_from)
self.add_event(account, obj.jid_from, event)
if helpers.allow_showing_notification(account):
path = gtkgui_helpers.get_icon_path('gajim-gc_invitation', 48)
@ -845,7 +848,8 @@ class Interface:
ft.show_send_error(file_props)
return
self.add_event(account, jid, 'file-send-error', file_props)
event = events.FileSendErrorEvent(file_props)
self.add_event(account, jid, event)
if helpers.allow_showing_notification(account):
path = gtkgui_helpers.get_icon_path('gajim-ft_error', 48)
@ -904,11 +908,14 @@ class Interface:
return
if errno in (-4, -5):
event_class = events.FileErrorEvent
msg_type = 'file-error'
else:
event_class = events.FileRequestErrorEvent
msg_type = 'file-request-error'
self.add_event(obj.conn.name, obj.jid, msg_type, obj.file_props)
event = event_class(obj.file_props)
self.add_event(obj.conn.name, obj.jid, event)
if helpers.allow_showing_notification(obj.conn.name):
# check if we should be notified
@ -942,7 +949,8 @@ class Interface:
self.instances['file_transfers'].show_file_request(account, contact,
obj.file_props)
return
self.add_event(account, obj.jid, 'file-request', obj.file_props)
event = events.FileRequestEvent(obj.file_props)
self.add_event(account, obj.jid, event)
if helpers.allow_showing_notification(account):
path = gtkgui_helpers.get_icon_path('gajim-ft_request', 48)
txt = _('%s wants to send you a file.') % gajim.get_name_from_jid(
@ -1040,12 +1048,15 @@ class Interface:
event_type = ''
if file_props.error == 0 and gajim.config.get(
'notify_on_file_complete'):
event_class = events.FileCompletedEvent
msg_type = 'file-completed'
event_type = _('File Transfer Completed')
elif file_props.error in (-1, -6):
event_class = events.FileStoppedEvent
msg_type = 'file-stopped'
event_type = _('File Transfer Stopped')
elif file_props.error == -10:
event_class = events.FileHashErrorEvent
msg_type = 'file-hash-error'
event_type = _('File Transfer Failed')
@ -1058,7 +1069,8 @@ class Interface:
return
if msg_type:
self.add_event(account, jid, msg_type, file_props)
event = event_class(file_props)
self.add_event(account, jid, event)
if file_props is not None:
if file_props.type_ == 'r':
@ -1261,8 +1273,8 @@ class Interface:
content_types)
return
self.add_event(account, obj.jid, 'jingle-incoming', (obj.fjid, obj.sid,
content_types))
event = events.JingleIncomingEvent(obj.fjid, obj.sid, content_types)
self.add_event(account, obj.jid, event)
if helpers.allow_showing_notification(account):
# TODO: we should use another pixmap ;-)
@ -1620,7 +1632,7 @@ class Interface:
### Methods dealing with gajim.events
################################################################################
def add_event(self, account, jid, type_, event_args):
def add_event(self, account, jid, event):
"""
Add an event to the gajim.events var
"""
@ -1628,25 +1640,22 @@ class Interface:
# Do we have a queue?
jid = gajim.get_jid_without_resource(jid)
no_queue = len(gajim.events.get_events(account, jid)) == 0
# type_ can be gc-invitation file-send-error file-error
# file-request-error file-request file-completed file-stopped
# file-hash-error jingle-incoming
# event can be in common.events.*
# event_type can be in advancedNotificationWindow.events_list
event_types = {'file-request': 'ft_request',
'file-completed': 'ft_finished'}
event_type = event_types.get(type_)
event_type = event_types.get(event.type_)
show_in_roster = notify.get_show_in_roster(event_type, account, jid)
show_in_systray = notify.get_show_in_systray(event_type, account, jid)
event = gajim.events.create_event(type_, event_args,
show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
event.show_in_roster = show_in_roster
event.show_in_systray = show_in_systray
gajim.events.add_event(account, jid, event)
self.roster.show_title()
if no_queue: # We didn't have a queue: we change icons
if not gajim.contacts.get_contact_with_highest_priority(account,
jid):
if type_ == 'gc-invitation':
if event.type_ == 'gc-invitation':
self.roster.add_groupchat(jid, account, status='offline')
else:
# add contact to roster ("Not In The Roster") if he is not
@ -1692,9 +1701,9 @@ class Interface:
return
if type_ == 'printed_chat':
ctrl = event.parameters[2]
ctrl = event.control
elif type_ == 'chat':
session = event.parameters[8]
session = event.session
ctrl = session.control
elif type_ == '':
ctrl = self.msg_win_mgr.get_control(fjid, account)
@ -1732,9 +1741,9 @@ class Interface:
return
if type_ == 'printed_pm':
ctrl = event.parameters[2]
ctrl = event.control
elif type_ == 'pm':
session = event.parameters[8]
session = event.session
if session and session.control:
ctrl = session.control
@ -1780,21 +1789,19 @@ class Interface:
helpers.launch_browser_mailer('url', url)
elif type_ == 'gc-invitation':
event = gajim.events.get_first_event(account, jid, type_)
data = event.parameters
dialogs.InvitationReceivedDialog(account, data[0], jid, data[2],
data[1], data[3])
dialogs.InvitationReceivedDialog(account, event.room_jid, jid,
event.password, event.reason, event.is_continued)
gajim.events.remove_events(account, jid, event)
self.roster.draw_contact(jid, account)
elif type_ == 'subscription_request':
event = gajim.events.get_first_event(account, jid, type_)
data = event.parameters
dialogs.SubscriptionRequestWindow(jid, data[0], account, data[1])
dialogs.SubscriptionRequestWindow(jid, event.text, account,
event.nick)
gajim.events.remove_events(account, jid, event)
self.roster.draw_contact(jid, account)
elif type_ == 'unsubscribed':
event = gajim.events.get_first_event(account, jid, type_)
contact = event.parameters
self.show_unsubscribed_dialog(account, contact)
self.show_unsubscribed_dialog(account, event.contact)
gajim.events.remove_events(account, jid, event)
self.roster.draw_contact(jid, account)
if w:

View File

@ -1965,9 +1965,9 @@ class RosterWindow:
for ev in event_list:
if ev.type_ != 'printed_chat':
continue
if len(ev.parameters) > 3 and ev.parameters[3]:
if ev.msg_log_id:
# There is a msg_log_id
msg_log_ids.append(ev.parameters[3])
msg_log_ids.append(ev.msg_log_id)
if msg_log_ids:
gajim.logger.set_read_messages(msg_log_ids)
@ -1991,59 +1991,60 @@ class RosterWindow:
"""
If an event was handled, return True, else return False
"""
data = event.parameters
ft = gajim.interface.instances['file_transfers']
event = gajim.events.get_first_event(account, jid, event.type_)
if event.type_ == 'normal':
dialogs.SingleMessageWindow(account, jid,
action='receive', from_whom=jid, subject=data[1],
message=data[0], resource=data[5], session=data[8],
form_node=data[9])
action='receive', from_whom=jid, subject=event.subject,
message=event.message, resource=event.resource,
session=event.session, form_node=event.form_node)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'file-request':
contact = gajim.contacts.get_contact_with_highest_priority(account,
jid)
ft.show_file_request(account, contact, data)
ft.show_file_request(account, contact, event.file_props)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ in ('file-request-error', 'file-send-error'):
ft.show_send_error(data)
ft.show_send_error(event.file_props)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ in ('file-error', 'file-stopped'):
msg_err = ''
if data.error == -1:
if event.file_props.error == -1:
msg_err = _('Remote contact stopped transfer')
elif data.error == -6:
elif event.file_props.error == -6:
msg_err = _('Error opening file')
ft.show_stopped(jid, data, error_msg=msg_err)
ft.show_stopped(jid, event.file_props, error_msg=msg_err)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'file-hash-error':
ft.show_hash_error(jid, data, account)
ft.show_hash_error(jid, event.file_props, account)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'file-completed':
ft.show_completed(jid, data)
ft.show_completed(jid, event.file_props)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'gc-invitation':
dialogs.InvitationReceivedDialog(account, data[0], data[4], data[2],
data[1], is_continued=data[3])
dialogs.InvitationReceivedDialog(account, event.room_jid,
event.jid_from, event.password, event.reason,
is_continued=event.is_continued)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'subscription_request':
dialogs.SubscriptionRequestWindow(jid, data[0], account, data[1])
dialogs.SubscriptionRequestWindow(jid, event.text, account,
event.nick)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'unsubscribed':
gajim.interface.show_unsubscribed_dialog(account, data)
gajim.interface.show_unsubscribed_dialog(account, event.contact)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'jingle-incoming':
peerjid, sid, content_types = data
dialogs.VoIPCallReceivedDialog(account, peerjid, sid, content_types)
dialogs.VoIPCallReceivedDialog(account, event.peerjid, event.sid,
event.content_types)
gajim.events.remove_events(account, jid, event)
return True
return False
@ -4160,7 +4161,7 @@ class RosterWindow:
session = None
if first_ev:
if first_ev.type_ in ('chat', 'normal'):
session = first_ev.parameters[8]
session = first_ev.session
fjid = jid
if resource:
fjid += '/' + resource

View File

@ -23,6 +23,7 @@
from common import helpers
from common import events
from common import exceptions
from common import gajim
from common import stanza_session
@ -235,11 +236,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
obj.popup = helpers.allow_popup_window(self.conn.name)
type_ = 'chat'
event_t = events.ChatEvent
event_type = 'message_received'
if obj.mtype == 'normal':
type_ = 'normal'
event_t = events.NormalEvent
event_type = 'single_message_received'
if self.control and obj.mtype != 'normal':
@ -253,10 +254,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if (not self.control and obj.mtype != 'normal') or \
(obj.mtype == 'normal' and not obj.popup):
event = gajim.events.create_event(type_, (obj.msgtxt, obj.subject,
obj.mtype, obj.timestamp, obj.encrypted, obj.resource,
obj.msg_log_id, obj.xhtml, self, obj.form_node, obj.displaymarking,
obj.forwarded and obj.sent),
event = event_t(obj.msgtxt, obj.subject, obj.mtype, obj.timestamp,
obj.encrypted, obj.resource, obj.msg_log_id, xhtml=obj.xhtml,
session=self, form_node=obj.form_node,
displaymarking=obj.displaymarking,
sent_forwarded=obj.forwarded and obj.sent,
show_in_roster=obj.show_in_roster,
show_in_systray=obj.show_in_systray)
@ -338,11 +340,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
return
# We save it in a queue
type_ = 'chat'
event_t = events.ChatEvent
event_type = 'message_received'
if msg_type == 'normal':
type_ = 'normal'
event_t = events.NormalEvent
event_type = 'single_message_received'
show_in_roster = notify.get_show_in_roster(event_type, self.conn.name,
@ -350,10 +352,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
show_in_systray = notify.get_show_in_systray(event_type, self.conn.name,
contact)
event = gajim.events.create_event(type_, (msg, subject, msg_type, tim,
encrypted, resource, msg_log_id, xhtml, self, form_node, displaymarking,
False), show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
event = event_t(msg, subject, msg_type, tim, encrypted, resource,
msg_log_id, xhtml=xhtml, session=self, form_node=form_node,
displaymarking=displaymarking, sent_forwarded=False,
show_in_roster=obj.show_in_roster,
show_in_systray=obj.show_in_systray)
gajim.events.add_event(self.conn.name, fjid, event)