in notifications say the message and do not dup info that new msg is in. fixes #1790
This commit is contained in:
parent
39b2c854d4
commit
befc5ac529
2 changed files with 30 additions and 26 deletions
54
src/gajim.py
54
src/gajim.py
|
@ -452,13 +452,15 @@ 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))
|
# chatstate))
|
||||||
|
|
||||||
|
|
||||||
jid = gajim.get_jid_without_resource(array[0])
|
full_jid_with_resource = array[0]
|
||||||
resource = gajim.get_resource_from_jid(array[0])
|
jid = gajim.get_jid_without_resource(full_jid_with_resource)
|
||||||
fjid = array[0]
|
resource = gajim.get_resource_from_jid(full_jid_with_resource)
|
||||||
|
|
||||||
|
message = array[1]
|
||||||
msg_type = array[4]
|
msg_type = array[4]
|
||||||
chatstate = array[6]
|
chatstate = array[6]
|
||||||
msg_id = array[7]
|
msg_id = array[7]
|
||||||
|
@ -491,7 +493,7 @@ class Interface:
|
||||||
|
|
||||||
# THIS MUST BE AFTER chatstates handling
|
# THIS MUST BE AFTER chatstates handling
|
||||||
# AND BEFORE playsound (else we here sounding on chatstates!)
|
# AND BEFORE playsound (else we here sounding on chatstates!)
|
||||||
if not array[1]: # empty message text
|
if not message: # empty message text
|
||||||
return
|
return
|
||||||
|
|
||||||
first = False
|
first = False
|
||||||
|
@ -502,9 +504,9 @@ class Interface:
|
||||||
elif chat_control and chat_control.type_id == message_control.TYPE_GC:
|
elif chat_control and chat_control.type_id == message_control.TYPE_GC:
|
||||||
# It's a Private message
|
# It's a Private message
|
||||||
pm = True
|
pm = True
|
||||||
if not self.msg_win_mgr.has_window(fjid, account) and \
|
if not self.msg_win_mgr.has_window(full_jid_with_resource, account) and \
|
||||||
not gajim.awaiting_events[account].has_key(fjid):
|
not gajim.awaiting_events[account].has_key(full_jid_with_resource):
|
||||||
first =True
|
first = True
|
||||||
if gajim.config.get_per('soundevents', 'first_message_received',
|
if gajim.config.get_per('soundevents', 'first_message_received',
|
||||||
'enabled') and first:
|
'enabled') and first:
|
||||||
helpers.play_sound('first_message_received')
|
helpers.play_sound('first_message_received')
|
||||||
|
@ -514,20 +516,20 @@ class Interface:
|
||||||
|
|
||||||
jid_of_control = jid
|
jid_of_control = jid
|
||||||
if pm:
|
if pm:
|
||||||
room_jid, nick = gajim.get_room_and_nick_from_fjid(fjid)
|
room_jid, nick = gajim.get_room_and_nick_from_fjid(full_jid_with_resource)
|
||||||
if first:
|
if first:
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
room_name,t = gajim.get_room_name_and_server_from_room_jid(
|
room_name,t = gajim.get_room_name_and_server_from_room_jid(
|
||||||
room_jid)
|
room_jid)
|
||||||
txt = _('%(nickname)s in room %(room_name)s has sent you a new '
|
txt = _('%(nickname)s in room %(room_name)s says: %(message)s') %\
|
||||||
'message.') % {'nickname': nick, 'room_name': room_name}
|
{'nickname': nick, 'room_name': room_name, 'message': message}
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'priv_msg_recv.png')
|
'priv_msg_recv.png')
|
||||||
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
|
||||||
notify.notify(_('New Private Message'), fjid, account, 'pm',
|
notify.notify(_('New Private Message'), full_jid_with_resource,
|
||||||
path_to_image = path, text = txt)
|
account, 'pm', path_to_image = path, text = txt)
|
||||||
|
|
||||||
chat_control.on_private_message(nick, array[1], array[2])
|
chat_control.on_private_message(nick, message, array[2])
|
||||||
return
|
return
|
||||||
|
|
||||||
# THIS HAS TO BE AFTER PM handling so we can get PMs
|
# THIS HAS TO BE AFTER PM handling so we can get PMs
|
||||||
|
@ -539,7 +541,7 @@ class Interface:
|
||||||
account, jid)
|
account, jid)
|
||||||
# Look for a chat control that has the given resource, or default to one
|
# Look for a chat control that has the given resource, or default to one
|
||||||
# without resource
|
# without resource
|
||||||
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account)
|
||||||
if ctrl:
|
if ctrl:
|
||||||
chat_control = ctrl
|
chat_control = ctrl
|
||||||
elif not highest_contact or not highest_contact.resource:
|
elif not highest_contact or not highest_contact.resource:
|
||||||
|
@ -548,12 +550,14 @@ class Interface:
|
||||||
jid_of_control = jid
|
jid_of_control = jid
|
||||||
elif resource != highest_contact.resource:
|
elif resource != highest_contact.resource:
|
||||||
chat_control = None
|
chat_control = None
|
||||||
jid_of_control = fjid
|
jid_of_control = full_jid_with_resource
|
||||||
|
|
||||||
if first:
|
if first:
|
||||||
if gajim.config.get('notify_on_new_message'):
|
if gajim.config.get('notify_on_new_message'):
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
txt = _('%s has sent you a new message.') % gajim.get_name_from_jid(account, jid)
|
txt = _('%(nickname)s says: %(message)s') % \
|
||||||
|
{'nickname': gajim.get_name_from_jid(account, jid),
|
||||||
|
'message': message}
|
||||||
if msg_type == 'normal': # single message
|
if msg_type == 'normal': # single message
|
||||||
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
|
||||||
'single_msg_recv.png')
|
'single_msg_recv.png')
|
||||||
|
@ -567,23 +571,23 @@ class Interface:
|
||||||
notify.notify(_('New Message'), jid_of_control, account,
|
notify.notify(_('New Message'), jid_of_control, account,
|
||||||
msg_type, path_to_image = path, text = txt)
|
msg_type, path_to_image = path, text = txt)
|
||||||
|
|
||||||
# array: (contact, msg, time, encrypted, msg_type, subject)
|
# array: (jid, msg, time, encrypted, msg_type, subject)
|
||||||
self.roster.on_message(jid, array[1], array[2], account, array[3],
|
self.roster.on_message(jid, message, array[2], account, array[3],
|
||||||
msg_type, array[5], resource)
|
msg_type, array[5], resource)
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('NewMessage', (account, array))
|
self.remote_ctrl.raise_signal('NewMessage', (account, array))
|
||||||
|
|
||||||
def handle_event_msgerror(self, account, array):
|
def handle_event_msgerror(self, account, array):
|
||||||
#('MSGERROR', account, (jid, error_code, error_msg, msg, time))
|
#'MSGERROR' (account, (jid, error_code, error_msg, msg, time))
|
||||||
fjid = array[0]
|
full_jid_with_resource = array[0]
|
||||||
jids = fjid.split('/', 1)
|
jids = full_jid_with_resource.split('/', 1)
|
||||||
jid = jids[0]
|
jid = jids[0]
|
||||||
gcs = self.msg_win_mgr.get_controls(message_control.TYPE_GC)
|
gcs = self.msg_win_mgr.get_controls(message_control.TYPE_GC)
|
||||||
for gc_control in gcs:
|
for gc_control in gcs:
|
||||||
if jid == gc_control.contact.jid:
|
if jid == gc_control.contact.jid:
|
||||||
if len(jids) > 1: # it's a pm
|
if len(jids) > 1: # it's a pm
|
||||||
nick = jids[1]
|
nick = jids[1]
|
||||||
if not self.msg_win_mgr.get_control(fjid, account):
|
if not self.msg_win_mgr.get_control(full_jid_with_resource, account):
|
||||||
tv = gc_control.list_treeview
|
tv = gc_control.list_treeview
|
||||||
model = tv.get_model()
|
model = tv.get_model()
|
||||||
i = gc_control.get_contact_iter(nick)
|
i = gc_control.get_contact_iter(nick)
|
||||||
|
@ -595,7 +599,7 @@ class Interface:
|
||||||
name = nick, show = show)
|
name = nick, show = show)
|
||||||
c = gajim.contacts.contact_from_gc_contact(gc_c)
|
c = gajim.contacts.contact_from_gc_contact(gc_c)
|
||||||
self.roster.new_chat(c, account, private_chat = True)
|
self.roster.new_chat(c, account, private_chat = True)
|
||||||
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account)
|
||||||
ctrl.print_conversation('Error %s: %s' % (array[1], array[2]),
|
ctrl.print_conversation('Error %s: %s' % (array[1], array[2]),
|
||||||
'status')
|
'status')
|
||||||
return
|
return
|
||||||
|
@ -806,7 +810,7 @@ class Interface:
|
||||||
self.remote_ctrl.raise_signal('OsInfo', (account, array))
|
self.remote_ctrl.raise_signal('OsInfo', (account, array))
|
||||||
|
|
||||||
def handle_event_gc_notify(self, account, array):
|
def handle_event_gc_notify(self, account, array):
|
||||||
#('GC_NOTIFY', account, (room_jid, show, status, nick,
|
#'GC_NOTIFY' (account, (room_jid, show, status, nick,
|
||||||
# role, affiliation, jid, reason, actor, statusCode, newNick))
|
# role, affiliation, jid, reason, actor, statusCode, newNick))
|
||||||
nick = array[3]
|
nick = array[3]
|
||||||
if not nick:
|
if not nick:
|
||||||
|
|
|
@ -11052,7 +11052,7 @@ Custom</property>
|
||||||
<property name="yalign">0.5</property>
|
<property name="yalign">0.5</property>
|
||||||
<property name="xpad">0</property>
|
<property name="xpad">0</property>
|
||||||
<property name="ypad">0</property>
|
<property name="ypad">0</property>
|
||||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
<property name="ellipsize">PANGO_ELLIPSIZE_END</property>
|
||||||
<property name="width_chars">-1</property>
|
<property name="width_chars">-1</property>
|
||||||
<property name="single_line_mode">False</property>
|
<property name="single_line_mode">False</property>
|
||||||
<property name="angle">0</property>
|
<property name="angle">0</property>
|
||||||
|
|
Loading…
Add table
Reference in a new issue