pending events are now in objects rather that storing parameters in tuple
This commit is contained in:
parent
fbdb7656af
commit
0530308a99
|
@ -46,6 +46,7 @@ import history_window
|
||||||
import notify
|
import notify
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from common import events
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
|
@ -912,20 +913,23 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
||||||
# other_tags_for_text == ['marked'] --> highlighted gc message
|
# other_tags_for_text == ['marked'] --> highlighted gc message
|
||||||
if gc_message:
|
if gc_message:
|
||||||
if 'marked' in other_tags_for_text:
|
if 'marked' in other_tags_for_text:
|
||||||
type_ = 'printed_marked_gc_msg'
|
event_type = events.PrintedMarkedGcMsgEvent
|
||||||
else:
|
else:
|
||||||
type_ = 'printed_gc_msg'
|
event_type = events.PrintedGcMsgEvent
|
||||||
event = 'gc_message_received'
|
event = 'gc_message_received'
|
||||||
else:
|
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'
|
event = 'message_received'
|
||||||
show_in_roster = notify.get_show_in_roster(event,
|
show_in_roster = notify.get_show_in_roster(event,
|
||||||
self.account, self.contact, self.session)
|
self.account, self.contact, self.session)
|
||||||
show_in_systray = notify.get_show_in_systray(event,
|
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,
|
event = event_type(text, subject, self, msg_log_id,
|
||||||
msg_log_id), show_in_roster=show_in_roster,
|
show_in_roster=show_in_roster,
|
||||||
show_in_systray=show_in_systray)
|
show_in_systray=show_in_systray)
|
||||||
gajim.events.add_event(self.account, full_jid, event)
|
gajim.events.add_event(self.account, full_jid, event)
|
||||||
# We need to redraw contact if we show in roster
|
# We need to redraw contact if we show in roster
|
||||||
|
@ -2677,7 +2681,7 @@ class ChatControl(ChatControlBase):
|
||||||
|
|
||||||
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
||||||
account=self.account, jid=self.contact.jid, chatstate=state,
|
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
|
contact.our_chatstate = state
|
||||||
if state == 'active':
|
if state == 'active':
|
||||||
|
@ -3010,23 +3014,20 @@ class ChatControl(ChatControlBase):
|
||||||
for event in events:
|
for event in events:
|
||||||
if event.type_ != self.type_id:
|
if event.type_ != self.type_id:
|
||||||
continue
|
continue
|
||||||
data = event.parameters
|
if event.kind == 'error':
|
||||||
kind = data[2]
|
|
||||||
if kind == 'error':
|
|
||||||
kind = 'info'
|
kind = 'info'
|
||||||
else:
|
else:
|
||||||
kind = 'print_queue'
|
kind = 'print_queue'
|
||||||
if data[11]:
|
if event.sent_forwarded:
|
||||||
kind = 'out'
|
kind = 'out'
|
||||||
dm = data[10]
|
self.print_conversation(event.message, kind, tim=event.time,
|
||||||
self.print_conversation(data[0], kind, tim=data[3],
|
encrypted=event.encrypted, subject=event.subject,
|
||||||
encrypted=data[4], subject=data[1], xhtml=data[7],
|
xhtml=event.xhtml, displaymarking=event.displaymarking)
|
||||||
displaymarking=dm)
|
if isinstance(event.msg_log_id, int):
|
||||||
if len(data) > 6 and isinstance(data[6], int):
|
message_ids.append(event.msg_log_id)
|
||||||
message_ids.append(data[6])
|
|
||||||
|
|
||||||
if len(data) > 8 and not self.session:
|
if event.session and not self.session:
|
||||||
self.set_session(data[8])
|
self.set_session(event.session)
|
||||||
if message_ids:
|
if message_ids:
|
||||||
gajim.logger.set_read_messages(message_ids)
|
gajim.logger.set_read_messages(message_ids)
|
||||||
gajim.events.remove_events(self.account, jid_with_resource,
|
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_):
|
def _get_file_props_event(self, file_props, type_):
|
||||||
evs = gajim.events.get_events(self.account, self.contact.jid, [type_])
|
evs = gajim.events.get_events(self.account, self.contact.jid, [type_])
|
||||||
for ev in evs:
|
for ev in evs:
|
||||||
if ev.parameters == file_props:
|
if ev.file_props == file_props:
|
||||||
return ev
|
return ev
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -3322,15 +3323,13 @@ class ChatControl(ChatControlBase):
|
||||||
self._add_info_bar_message(markup, [b], file_props, Gtk.MessageType.ERROR)
|
self._add_info_bar_message(markup, [b], file_props, Gtk.MessageType.ERROR)
|
||||||
|
|
||||||
def _on_accept_gc_invitation(self, widget, event):
|
def _on_accept_gc_invitation(self, widget, event):
|
||||||
room_jid = event.parameters[0]
|
|
||||||
password = event.parameters[2]
|
|
||||||
is_continued = event.parameters[3]
|
|
||||||
try:
|
try:
|
||||||
if is_continued:
|
if event.is_continued:
|
||||||
gajim.interface.join_gc_room(self.account, room_jid,
|
gajim.interface.join_gc_room(self.account, event.room_jid,
|
||||||
gajim.nicks[self.account], password, is_continued=True)
|
gajim.nicks[self.account], event.password,
|
||||||
|
is_continued=True)
|
||||||
else:
|
else:
|
||||||
dialogs.JoinGroupchatWindow(self.account, room_jid)
|
dialogs.JoinGroupchatWindow(self.account, event.room_jid)
|
||||||
except GajimGeneralException:
|
except GajimGeneralException:
|
||||||
pass
|
pass
|
||||||
gajim.events.remove_events(self.account, self.contact.jid, event=event)
|
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)
|
gajim.events.remove_events(self.account, self.contact.jid, event=event)
|
||||||
|
|
||||||
def _get_gc_invitation(self, event):
|
def _get_gc_invitation(self, event):
|
||||||
room_jid = event.parameters[0]
|
markup = '<b>%s:</b> %s' % (_('Groupchat Invitation'), event.room_jid)
|
||||||
comment = event.parameters[1]
|
if event.comment:
|
||||||
markup = '<b>%s:</b> %s' % (_('Groupchat Invitation'), room_jid)
|
markup += ' (%s)' % event.comment
|
||||||
if comment:
|
|
||||||
markup += ' (%s)' % comment
|
|
||||||
b1 = Gtk.Button(_('_Join'))
|
b1 = Gtk.Button(_('_Join'))
|
||||||
b1.connect('clicked', self._on_accept_gc_invitation, event)
|
b1.connect('clicked', self._on_accept_gc_invitation, event)
|
||||||
b2 = Gtk.Button(stock=Gtk.STOCK_CANCEL)
|
b2 = Gtk.Button(stock=Gtk.STOCK_CANCEL)
|
||||||
b2.connect('clicked', self._on_cancel_gc_invitation, event)
|
b2.connect('clicked', self._on_cancel_gc_invitation, event)
|
||||||
self._add_info_bar_message(markup, [b1, b2], event.parameters,
|
self._add_info_bar_message(markup, [b1, b2], (event.room_jid,
|
||||||
Gtk.MessageType.QUESTION)
|
event.comment), Gtk.MessageType.QUESTION)
|
||||||
|
|
||||||
def on_event_added(self, event):
|
def on_event_added(self, event):
|
||||||
if event.account != self.account:
|
if event.account != self.account:
|
||||||
|
@ -3357,19 +3354,19 @@ class ChatControl(ChatControlBase):
|
||||||
if event.jid != self.contact.jid:
|
if event.jid != self.contact.jid:
|
||||||
return
|
return
|
||||||
if event.type_ == 'file-request':
|
if event.type_ == 'file-request':
|
||||||
self._got_file_request(event.parameters)
|
self._got_file_request(event.file_props)
|
||||||
elif event.type_ == 'file-completed':
|
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'):
|
elif event.type_ in ('file-error', 'file-stopped'):
|
||||||
msg_err = ''
|
msg_err = ''
|
||||||
if event.parameters.error == -1:
|
if event.file_props.error == -1:
|
||||||
msg_err = _('Remote contact stopped transfer')
|
msg_err = _('Remote contact stopped transfer')
|
||||||
elif event.parameters.error == -6:
|
elif event.file_props.error == -6:
|
||||||
msg_err = _('Error opening file')
|
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)
|
_('File transfer stopped'), msg_err)
|
||||||
elif event.type_ in ('file-request-error', 'file-send-error'):
|
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'),
|
_('File transfer cancelled'),
|
||||||
_('Connection with peer cannot be established.'))
|
_('Connection with peer cannot be established.'))
|
||||||
elif event.type_ == 'gc-invitation':
|
elif event.type_ == 'gc-invitation':
|
||||||
|
@ -3392,11 +3389,11 @@ class ChatControl(ChatControlBase):
|
||||||
removed = False
|
removed = False
|
||||||
for ib_msg in self.info_bar_queue:
|
for ib_msg in self.info_bar_queue:
|
||||||
if ev.type_ == 'gc-invitation':
|
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)
|
self.info_bar_queue.remove(ib_msg)
|
||||||
removed = True
|
removed = True
|
||||||
else: # file-*
|
else: # file-*
|
||||||
if ib_msg[2] == ev.parameters:
|
if ib_msg[2] == ev.file_props:
|
||||||
self.info_bar_queue.remove(ib_msg)
|
self.info_bar_queue.remove(ib_msg)
|
||||||
removed = True
|
removed = True
|
||||||
if removed:
|
if removed:
|
||||||
|
|
|
@ -287,9 +287,9 @@ class ForwardMessagesCommand(AdHocCommand):
|
||||||
if ev_typ == 'printed_chat':
|
if ev_typ == 'printed_chat':
|
||||||
ev_typ = 'chat'
|
ev_typ = 'chat'
|
||||||
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
||||||
account=account, jid=j, message=event.parameters[0],
|
account=account, jid=j, message=event.message, type_=ev_typ,
|
||||||
type_=ev_typ, subject=event.parameters[1],
|
subject=event.subject, resource=resource, forward_from=jid,
|
||||||
resource=resource, forward_from=jid, delayed=event.time_))
|
delayed=event.time_))
|
||||||
|
|
||||||
# Inform other client of completion
|
# Inform other client of completion
|
||||||
response, cmd = self.buildResponse(request, status = 'completed')
|
response, cmd = self.buildResponse(request, status = 'completed')
|
||||||
|
@ -321,10 +321,9 @@ class FwdMsgThenDisconnectCommand(AdHocCommand):
|
||||||
if ev_typ == 'printed_chat':
|
if ev_typ == 'printed_chat':
|
||||||
ev_typ = 'chat'
|
ev_typ = 'chat'
|
||||||
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
gajim.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
||||||
account=account, jid=j, message=event.parameters[0],
|
account=account, jid=j, message=event.message, type_=ev_typ,
|
||||||
type_=ev_typ, subject=event.parameters[1],
|
subject=event.subject, resource=resource, forward_from=jid,
|
||||||
resource=resource, forward_from=jid, delayed=event.time_,
|
delayed=event.time_, now=True))
|
||||||
now=True))
|
|
||||||
|
|
||||||
response, cmd = self.buildResponse(request, status = 'completed')
|
response, cmd = self.buildResponse(request, status = 'completed')
|
||||||
cmd.addChild('note', {}, _('The status has been changed.'))
|
cmd.addChild('note', {}, _('The status has been changed.'))
|
||||||
|
|
|
@ -31,8 +31,7 @@ class Event:
|
||||||
Information concerning each event
|
Information concerning each event
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, type_, time_, parameters, show_in_roster=False,
|
def __init__(self, time_=None, show_in_roster=False, show_in_systray=True):
|
||||||
show_in_systray=True):
|
|
||||||
"""
|
"""
|
||||||
type_ in chat, normal, file-request, file-error, file-completed,
|
type_ in chat, normal, file-request, file-error, file-completed,
|
||||||
file-request-error, file-send-error, file-stopped, gc_msg, pm,
|
file-request-error, file-send-error, file-stopped, gc_msg, pm,
|
||||||
|
@ -41,27 +40,138 @@ class Event:
|
||||||
|
|
||||||
parameters is (per type_):
|
parameters is (per type_):
|
||||||
chat, normal, pm: [message, subject, kind, time, encrypted, resource,
|
chat, normal, pm: [message, subject, kind, time, encrypted, resource,
|
||||||
msg_id]
|
msg_log_id]
|
||||||
where kind in error, incoming
|
where kind in error, incoming
|
||||||
file-*: file_props
|
file-*: file_props
|
||||||
gc_msg: None
|
gc_msg: None
|
||||||
printed_chat: [message, subject, control, msg_id]
|
printed_chat: [message, subject, control, msg_log_id]
|
||||||
printed_*: None
|
printed_*: None
|
||||||
messages that are already printed in chat, but not read
|
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]
|
subscription_request: [text, nick]
|
||||||
unsubscribed: contact
|
unsubscribed: contact
|
||||||
jingle-incoming: (fulljid, sessionid, content_types)
|
jingle-incoming: (fulljid, sessionid, content_types)
|
||||||
"""
|
"""
|
||||||
self.type_ = type_
|
if time_:
|
||||||
self.time_ = time_
|
self.time_ = time_
|
||||||
self.parameters = parameters
|
else:
|
||||||
|
self.time_ = time.time()
|
||||||
self.show_in_roster = show_in_roster
|
self.show_in_roster = show_in_roster
|
||||||
self.show_in_systray = show_in_systray
|
self.show_in_systray = show_in_systray
|
||||||
# Set when adding the event
|
# Set when adding the event
|
||||||
self.jid = None
|
self.jid = None
|
||||||
self.account = 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:
|
class Events:
|
||||||
"""
|
"""
|
||||||
Information concerning all events
|
Information concerning all events
|
||||||
|
@ -122,13 +232,6 @@ class Events:
|
||||||
def remove_account(self, account):
|
def remove_account(self, account):
|
||||||
del self._events[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):
|
def add_event(self, account, jid, event):
|
||||||
# No such account before ?
|
# No such account before ?
|
||||||
if account not in self._events:
|
if account not in self._events:
|
||||||
|
|
|
@ -96,8 +96,8 @@ class StanzaSession(object):
|
||||||
for j in (self.jid, self.jid.getStripped()):
|
for j in (self.jid, self.jid.getStripped()):
|
||||||
for event in gajim.events.get_events(self.conn.name, j, types=types):
|
for event in gajim.events.get_events(self.conn.name, j, types=types):
|
||||||
# the event wasn't in this session
|
# the event wasn't in this session
|
||||||
if (event.type_ == 'chat' and event.parameters[8] != self) or \
|
if (event.type_ == 'chat' and event.session != self) or \
|
||||||
(event.type_ == 'printed_chat' and event.parameters[2].session != \
|
(event.type_ == 'printed_chat' and event.control.session != \
|
||||||
self):
|
self):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -592,7 +592,7 @@ class FileTransfersWindow:
|
||||||
for ev_type in ('file-error', 'file-completed', 'file-request-error',
|
for ev_type in ('file-error', 'file-completed', 'file-request-error',
|
||||||
'file-send-error', 'file-stopped'):
|
'file-send-error', 'file-stopped'):
|
||||||
for event in gajim.events.get_events(account, jid, [ev_type]):
|
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.events.remove_events(account, jid, event)
|
||||||
gajim.interface.roster.draw_contact(jid, account)
|
gajim.interface.roster.draw_contact(jid, account)
|
||||||
gajim.interface.roster.show_title()
|
gajim.interface.roster.show_title()
|
||||||
|
|
|
@ -46,6 +46,7 @@ import cell_renderer_image
|
||||||
import dataforms_widget
|
import dataforms_widget
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
|
|
||||||
|
from common import events
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import dataforms
|
from common import dataforms
|
||||||
|
@ -1082,8 +1083,9 @@ class GroupchatControl(ChatControlBase):
|
||||||
fjid = self.room_jid + '/' + nick
|
fjid = self.room_jid + '/' + nick
|
||||||
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
|
no_queue = len(gajim.events.get_events(self.account, fjid)) == 0
|
||||||
|
|
||||||
event = gajim.events.create_event('pm', (msg, '', 'incoming', tim,
|
event = events.PmEvent(msg, '', 'incoming', tim, encrypted, '',
|
||||||
encrypted, '', msg_log_id, xhtml, session, None, displaymarking, False))
|
msg_log_id, xhtml=xhtml, session=session, form_node=None,
|
||||||
|
displaymarking=displaymarking, sent_forwarded=False)
|
||||||
gajim.events.add_event(self.account, fjid, event)
|
gajim.events.add_event(self.account, fjid, event)
|
||||||
|
|
||||||
autopopup = gajim.config.get('autopopup')
|
autopopup = gajim.config.get('autopopup')
|
||||||
|
|
|
@ -47,6 +47,7 @@ from gi.repository import GLib
|
||||||
|
|
||||||
from common import i18n
|
from common import i18n
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import events
|
||||||
|
|
||||||
from common import dbus_support
|
from common import dbus_support
|
||||||
if dbus_support.supported:
|
if dbus_support.supported:
|
||||||
|
@ -468,8 +469,8 @@ class Interface:
|
||||||
obj.user_nick)
|
obj.user_nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.add_event(account, obj.jid, 'subscription_request', (obj.status,
|
event = events.SubscriptionRequestEvent(obj.status, obj.user_nick)
|
||||||
obj.user_nick))
|
self.add_event(account, obj.jid, event)
|
||||||
|
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-subscription_request',
|
path = gtkgui_helpers.get_icon_path('gajim-subscription_request',
|
||||||
|
@ -526,7 +527,8 @@ class Interface:
|
||||||
self.show_unsubscribed_dialog(account, contact)
|
self.show_unsubscribed_dialog(account, contact)
|
||||||
return
|
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):
|
if helpers.allow_showing_notification(account):
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-unsubscribed', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-unsubscribed', 48)
|
||||||
|
@ -645,8 +647,9 @@ class Interface:
|
||||||
is_continued=obj.is_continued)
|
is_continued=obj.is_continued)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.add_event(account, obj.jid_from, 'gc-invitation', (obj.room_jid,
|
event = events.GcInvitationtEvent(obj.room_jid, obj.reason,
|
||||||
obj.reason, obj.password, obj.is_continued, obj.jid_from))
|
obj.password, obj.is_continued, obj.jid_from)
|
||||||
|
self.add_event(account, obj.jid_from, event)
|
||||||
|
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-gc_invitation', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-gc_invitation', 48)
|
||||||
|
@ -845,7 +848,8 @@ class Interface:
|
||||||
ft.show_send_error(file_props)
|
ft.show_send_error(file_props)
|
||||||
return
|
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):
|
if helpers.allow_showing_notification(account):
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-ft_error', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-ft_error', 48)
|
||||||
|
@ -904,11 +908,14 @@ class Interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
if errno in (-4, -5):
|
if errno in (-4, -5):
|
||||||
|
event_class = events.FileErrorEvent
|
||||||
msg_type = 'file-error'
|
msg_type = 'file-error'
|
||||||
else:
|
else:
|
||||||
|
event_class = events.FileRequestErrorEvent
|
||||||
msg_type = 'file-request-error'
|
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):
|
if helpers.allow_showing_notification(obj.conn.name):
|
||||||
# check if we should be notified
|
# check if we should be notified
|
||||||
|
@ -942,7 +949,8 @@ class Interface:
|
||||||
self.instances['file_transfers'].show_file_request(account, contact,
|
self.instances['file_transfers'].show_file_request(account, contact,
|
||||||
obj.file_props)
|
obj.file_props)
|
||||||
return
|
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):
|
if helpers.allow_showing_notification(account):
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-ft_request', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-ft_request', 48)
|
||||||
txt = _('%s wants to send you a file.') % gajim.get_name_from_jid(
|
txt = _('%s wants to send you a file.') % gajim.get_name_from_jid(
|
||||||
|
@ -1040,12 +1048,15 @@ class Interface:
|
||||||
event_type = ''
|
event_type = ''
|
||||||
if file_props.error == 0 and gajim.config.get(
|
if file_props.error == 0 and gajim.config.get(
|
||||||
'notify_on_file_complete'):
|
'notify_on_file_complete'):
|
||||||
|
event_class = events.FileCompletedEvent
|
||||||
msg_type = 'file-completed'
|
msg_type = 'file-completed'
|
||||||
event_type = _('File Transfer Completed')
|
event_type = _('File Transfer Completed')
|
||||||
elif file_props.error in (-1, -6):
|
elif file_props.error in (-1, -6):
|
||||||
|
event_class = events.FileStoppedEvent
|
||||||
msg_type = 'file-stopped'
|
msg_type = 'file-stopped'
|
||||||
event_type = _('File Transfer Stopped')
|
event_type = _('File Transfer Stopped')
|
||||||
elif file_props.error == -10:
|
elif file_props.error == -10:
|
||||||
|
event_class = events.FileHashErrorEvent
|
||||||
msg_type = 'file-hash-error'
|
msg_type = 'file-hash-error'
|
||||||
event_type = _('File Transfer Failed')
|
event_type = _('File Transfer Failed')
|
||||||
|
|
||||||
|
@ -1058,7 +1069,8 @@ class Interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
if msg_type:
|
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 is not None:
|
||||||
if file_props.type_ == 'r':
|
if file_props.type_ == 'r':
|
||||||
|
@ -1261,8 +1273,8 @@ class Interface:
|
||||||
content_types)
|
content_types)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.add_event(account, obj.jid, 'jingle-incoming', (obj.fjid, obj.sid,
|
event = events.JingleIncomingEvent(obj.fjid, obj.sid, content_types)
|
||||||
content_types))
|
self.add_event(account, obj.jid, event)
|
||||||
|
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
# TODO: we should use another pixmap ;-)
|
# TODO: we should use another pixmap ;-)
|
||||||
|
@ -1412,7 +1424,7 @@ class Interface:
|
||||||
'New SHA-1 fingerprint: %(new_sha1)s\nNew SHA-256 fingerprint: '
|
'New SHA-1 fingerprint: %(new_sha1)s\nNew SHA-256 fingerprint: '
|
||||||
'%(new_sha256)s\n\nDo you still want to connect '
|
'%(new_sha256)s\n\nDo you still want to connect '
|
||||||
'and update the fingerprint of the certificate?') % \
|
'and update the fingerprint of the certificate?') % \
|
||||||
{'account': account,
|
{'account': account,
|
||||||
'old_sha1': gajim.config.get_per('accounts', account, 'ssl_fingerprint_sha1'),
|
'old_sha1': gajim.config.get_per('accounts', account, 'ssl_fingerprint_sha1'),
|
||||||
'old_sha256': gajim.config.get_per('accounts', account, 'ssl_fingerprint_sha256'),
|
'old_sha256': gajim.config.get_per('accounts', account, 'ssl_fingerprint_sha256'),
|
||||||
'new_sha1': obj.new_fingerprint_sha1,
|
'new_sha1': obj.new_fingerprint_sha1,
|
||||||
|
@ -1620,7 +1632,7 @@ class Interface:
|
||||||
### Methods dealing with gajim.events
|
### 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
|
Add an event to the gajim.events var
|
||||||
"""
|
"""
|
||||||
|
@ -1628,25 +1640,22 @@ class Interface:
|
||||||
# Do we have a queue?
|
# Do we have a queue?
|
||||||
jid = gajim.get_jid_without_resource(jid)
|
jid = gajim.get_jid_without_resource(jid)
|
||||||
no_queue = len(gajim.events.get_events(account, jid)) == 0
|
no_queue = len(gajim.events.get_events(account, jid)) == 0
|
||||||
# type_ can be gc-invitation file-send-error file-error
|
# event can be in common.events.*
|
||||||
# file-request-error file-request file-completed file-stopped
|
|
||||||
# file-hash-error jingle-incoming
|
|
||||||
# event_type can be in advancedNotificationWindow.events_list
|
# event_type can be in advancedNotificationWindow.events_list
|
||||||
event_types = {'file-request': 'ft_request',
|
event_types = {'file-request': 'ft_request',
|
||||||
'file-completed': 'ft_finished'}
|
'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_roster = notify.get_show_in_roster(event_type, account, jid)
|
||||||
show_in_systray = notify.get_show_in_systray(event_type, account, jid)
|
show_in_systray = notify.get_show_in_systray(event_type, account, jid)
|
||||||
event = gajim.events.create_event(type_, event_args,
|
event.show_in_roster = show_in_roster
|
||||||
show_in_roster=show_in_roster,
|
event.show_in_systray = show_in_systray
|
||||||
show_in_systray=show_in_systray)
|
|
||||||
gajim.events.add_event(account, jid, event)
|
gajim.events.add_event(account, jid, event)
|
||||||
|
|
||||||
self.roster.show_title()
|
self.roster.show_title()
|
||||||
if no_queue: # We didn't have a queue: we change icons
|
if no_queue: # We didn't have a queue: we change icons
|
||||||
if not gajim.contacts.get_contact_with_highest_priority(account,
|
if not gajim.contacts.get_contact_with_highest_priority(account,
|
||||||
jid):
|
jid):
|
||||||
if type_ == 'gc-invitation':
|
if event.type_ == 'gc-invitation':
|
||||||
self.roster.add_groupchat(jid, account, status='offline')
|
self.roster.add_groupchat(jid, account, status='offline')
|
||||||
else:
|
else:
|
||||||
# add contact to roster ("Not In The Roster") if he is not
|
# add contact to roster ("Not In The Roster") if he is not
|
||||||
|
@ -1692,9 +1701,9 @@ class Interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
if type_ == 'printed_chat':
|
if type_ == 'printed_chat':
|
||||||
ctrl = event.parameters[2]
|
ctrl = event.control
|
||||||
elif type_ == 'chat':
|
elif type_ == 'chat':
|
||||||
session = event.parameters[8]
|
session = event.session
|
||||||
ctrl = session.control
|
ctrl = session.control
|
||||||
elif type_ == '':
|
elif type_ == '':
|
||||||
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
||||||
|
@ -1732,9 +1741,9 @@ class Interface:
|
||||||
return
|
return
|
||||||
|
|
||||||
if type_ == 'printed_pm':
|
if type_ == 'printed_pm':
|
||||||
ctrl = event.parameters[2]
|
ctrl = event.control
|
||||||
elif type_ == 'pm':
|
elif type_ == 'pm':
|
||||||
session = event.parameters[8]
|
session = event.session
|
||||||
|
|
||||||
if session and session.control:
|
if session and session.control:
|
||||||
ctrl = session.control
|
ctrl = session.control
|
||||||
|
@ -1780,21 +1789,19 @@ class Interface:
|
||||||
helpers.launch_browser_mailer('url', url)
|
helpers.launch_browser_mailer('url', url)
|
||||||
elif type_ == 'gc-invitation':
|
elif type_ == 'gc-invitation':
|
||||||
event = gajim.events.get_first_event(account, jid, type_)
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
data = event.parameters
|
dialogs.InvitationReceivedDialog(account, event.room_jid, jid,
|
||||||
dialogs.InvitationReceivedDialog(account, data[0], jid, data[2],
|
event.password, event.reason, event.is_continued)
|
||||||
data[1], data[3])
|
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
self.roster.draw_contact(jid, account)
|
self.roster.draw_contact(jid, account)
|
||||||
elif type_ == 'subscription_request':
|
elif type_ == 'subscription_request':
|
||||||
event = gajim.events.get_first_event(account, jid, type_)
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
data = event.parameters
|
dialogs.SubscriptionRequestWindow(jid, event.text, account,
|
||||||
dialogs.SubscriptionRequestWindow(jid, data[0], account, data[1])
|
event.nick)
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
self.roster.draw_contact(jid, account)
|
self.roster.draw_contact(jid, account)
|
||||||
elif type_ == 'unsubscribed':
|
elif type_ == 'unsubscribed':
|
||||||
event = gajim.events.get_first_event(account, jid, type_)
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
contact = event.parameters
|
self.show_unsubscribed_dialog(account, event.contact)
|
||||||
self.show_unsubscribed_dialog(account, contact)
|
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
self.roster.draw_contact(jid, account)
|
self.roster.draw_contact(jid, account)
|
||||||
if w:
|
if w:
|
||||||
|
|
|
@ -1965,9 +1965,9 @@ class RosterWindow:
|
||||||
for ev in event_list:
|
for ev in event_list:
|
||||||
if ev.type_ != 'printed_chat':
|
if ev.type_ != 'printed_chat':
|
||||||
continue
|
continue
|
||||||
if len(ev.parameters) > 3 and ev.parameters[3]:
|
if ev.msg_log_id:
|
||||||
# There is a 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:
|
if msg_log_ids:
|
||||||
gajim.logger.set_read_messages(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
|
If an event was handled, return True, else return False
|
||||||
"""
|
"""
|
||||||
data = event.parameters
|
|
||||||
ft = gajim.interface.instances['file_transfers']
|
ft = gajim.interface.instances['file_transfers']
|
||||||
event = gajim.events.get_first_event(account, jid, event.type_)
|
event = gajim.events.get_first_event(account, jid, event.type_)
|
||||||
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=event.subject,
|
||||||
message=data[0], resource=data[5], session=data[8],
|
message=event.message, resource=event.resource,
|
||||||
form_node=data[9])
|
session=event.session, form_node=event.form_node)
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'file-request':
|
elif event.type_ == 'file-request':
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
||||||
jid)
|
jid)
|
||||||
ft.show_file_request(account, contact, data)
|
ft.show_file_request(account, contact, event.file_props)
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ in ('file-request-error', 'file-send-error'):
|
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)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ in ('file-error', 'file-stopped'):
|
elif event.type_ in ('file-error', 'file-stopped'):
|
||||||
msg_err = ''
|
msg_err = ''
|
||||||
if data.error == -1:
|
if event.file_props.error == -1:
|
||||||
msg_err = _('Remote contact stopped transfer')
|
msg_err = _('Remote contact stopped transfer')
|
||||||
elif data.error == -6:
|
elif event.file_props.error == -6:
|
||||||
msg_err = _('Error opening file')
|
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)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'file-hash-error':
|
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)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'file-completed':
|
elif event.type_ == 'file-completed':
|
||||||
ft.show_completed(jid, data)
|
ft.show_completed(jid, event.file_props)
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'gc-invitation':
|
elif event.type_ == 'gc-invitation':
|
||||||
dialogs.InvitationReceivedDialog(account, data[0], data[4], data[2],
|
dialogs.InvitationReceivedDialog(account, event.room_jid,
|
||||||
data[1], is_continued=data[3])
|
event.jid_from, event.password, event.reason,
|
||||||
|
is_continued=event.is_continued)
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'subscription_request':
|
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)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'unsubscribed':
|
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)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
elif event.type_ == 'jingle-incoming':
|
elif event.type_ == 'jingle-incoming':
|
||||||
peerjid, sid, content_types = data
|
dialogs.VoIPCallReceivedDialog(account, event.peerjid, event.sid,
|
||||||
dialogs.VoIPCallReceivedDialog(account, peerjid, sid, content_types)
|
event.content_types)
|
||||||
gajim.events.remove_events(account, jid, event)
|
gajim.events.remove_events(account, jid, event)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -4160,7 +4161,7 @@ class RosterWindow:
|
||||||
session = None
|
session = None
|
||||||
if first_ev:
|
if first_ev:
|
||||||
if first_ev.type_ in ('chat', 'normal'):
|
if first_ev.type_ in ('chat', 'normal'):
|
||||||
session = first_ev.parameters[8]
|
session = first_ev.session
|
||||||
fjid = jid
|
fjid = jid
|
||||||
if resource:
|
if resource:
|
||||||
fjid += '/' + resource
|
fjid += '/' + resource
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
from common import helpers
|
from common import helpers
|
||||||
|
|
||||||
|
from common import events
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import stanza_session
|
from common import stanza_session
|
||||||
|
@ -235,11 +236,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
|
|
||||||
obj.popup = helpers.allow_popup_window(self.conn.name)
|
obj.popup = helpers.allow_popup_window(self.conn.name)
|
||||||
|
|
||||||
type_ = 'chat'
|
event_t = events.ChatEvent
|
||||||
event_type = 'message_received'
|
event_type = 'message_received'
|
||||||
|
|
||||||
if obj.mtype == 'normal':
|
if obj.mtype == 'normal':
|
||||||
type_ = 'normal'
|
event_t = events.NormalEvent
|
||||||
event_type = 'single_message_received'
|
event_type = 'single_message_received'
|
||||||
|
|
||||||
if self.control and obj.mtype != 'normal':
|
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 \
|
if (not self.control and obj.mtype != 'normal') or \
|
||||||
(obj.mtype == 'normal' and not obj.popup):
|
(obj.mtype == 'normal' and not obj.popup):
|
||||||
event = gajim.events.create_event(type_, (obj.msgtxt, obj.subject,
|
event = event_t(obj.msgtxt, obj.subject, obj.mtype, obj.timestamp,
|
||||||
obj.mtype, obj.timestamp, obj.encrypted, obj.resource,
|
obj.encrypted, obj.resource, obj.msg_log_id, xhtml=obj.xhtml,
|
||||||
obj.msg_log_id, obj.xhtml, self, obj.form_node, obj.displaymarking,
|
session=self, form_node=obj.form_node,
|
||||||
obj.forwarded and obj.sent),
|
displaymarking=obj.displaymarking,
|
||||||
|
sent_forwarded=obj.forwarded and obj.sent,
|
||||||
show_in_roster=obj.show_in_roster,
|
show_in_roster=obj.show_in_roster,
|
||||||
show_in_systray=obj.show_in_systray)
|
show_in_systray=obj.show_in_systray)
|
||||||
|
|
||||||
|
@ -338,11 +340,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
return
|
return
|
||||||
|
|
||||||
# We save it in a queue
|
# We save it in a queue
|
||||||
type_ = 'chat'
|
event_t = events.ChatEvent
|
||||||
event_type = 'message_received'
|
event_type = 'message_received'
|
||||||
|
|
||||||
if msg_type == 'normal':
|
if msg_type == 'normal':
|
||||||
type_ = 'normal'
|
event_t = events.NormalEvent
|
||||||
event_type = 'single_message_received'
|
event_type = 'single_message_received'
|
||||||
|
|
||||||
show_in_roster = notify.get_show_in_roster(event_type, self.conn.name,
|
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,
|
show_in_systray = notify.get_show_in_systray(event_type, self.conn.name,
|
||||||
contact)
|
contact)
|
||||||
|
|
||||||
event = gajim.events.create_event(type_, (msg, subject, msg_type, tim,
|
event = event_t(msg, subject, msg_type, tim, encrypted, resource,
|
||||||
encrypted, resource, msg_log_id, xhtml, self, form_node, displaymarking,
|
msg_log_id, xhtml=xhtml, session=self, form_node=form_node,
|
||||||
False), show_in_roster=show_in_roster,
|
displaymarking=displaymarking, sent_forwarded=False,
|
||||||
show_in_systray=show_in_systray)
|
show_in_roster=obj.show_in_roster,
|
||||||
|
show_in_systray=obj.show_in_systray)
|
||||||
|
|
||||||
gajim.events.add_event(self.conn.name, fjid, event)
|
gajim.events.add_event(self.conn.name, fjid, event)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue