Commit ff9bc4f9 authored by Philipp Hörist's avatar Philipp Hörist

Treat type normal messages as chat

parent 493d00bc
......@@ -810,8 +810,7 @@ def _nec_decrypted_message_received(self, obj):
return True
if obj.conn.name != self.account:
return
if not obj.properties.type.is_chat:
return
if obj.session.control != self:
return
......
......@@ -246,7 +246,6 @@ class Config:
'confirm_block': [opt_str, '', _('Show a confirmation dialog to block a contact? Empty string means never show the dialog.')],
'enable_negative_priority': [opt_bool, False, _('If enabled, you will be able to set a negative priority to your account in the Accounts window. BE CAREFUL, when you are logged in with a negative priority, you will NOT receive any message from your server.')],
'show_contacts_number': [opt_bool, True, _('If enabled, Gajim will show both the number of online and total contacts in account rows as well as in group rows.')],
'treat_incoming_messages': [opt_str, 'chat', _('Can be empty, \'chat\' or \'normal\'. If not empty, all incoming messages are treated as if they were of this type.')],
'scroll_roster_to_last_message': [opt_bool, True, _('If enabled, Gajim will scroll and select the contact who sent you the last message, if the chat window is not already opened.')],
'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
'max_conversation_lines': [opt_int, 500, _('Maximum number of lines that are printed in conversations. Oldest lines are cleared.')],
......
......@@ -367,10 +367,7 @@ def handle_incoming_msg_event(self, msg_obj):
# We don't want message preview, do_preview = False
self.popup_text = ''
if msg_obj.properties.type.is_normal: # single message
self.popup_msg_type = 'normal'
self.popup_event_type = _('New Single Message')
elif msg_obj.properties.is_muc_pm:
if msg_obj.properties.is_muc_pm:
self.popup_msg_type = 'pm'
self.popup_event_type = _('New Private Message')
else: # chat message
......
......@@ -85,9 +85,6 @@ def __init__(self, message, subject, kind, time_, encrypted, resource,
additional_data = AdditionalDataDict()
self.additional_data = additional_data
class NormalEvent(ChatEvent):
type_ = 'normal'
class PmEvent(ChatEvent):
type_ = 'pm'
......
......@@ -125,8 +125,6 @@ def _get_icon_name(obj):
if obj.notif_type == 'msg':
if obj.base_event.properties.is_muc_pm:
return 'gajim-priv_msg_recv'
if obj.base_event.properties.type.is_normal:
return 'gajim-single_msg_recv'
elif obj.notif_type == 'pres':
if obj.transport_name is not None:
......@@ -167,7 +165,7 @@ def popup(self, event_type, jid, account, type_='', icon_name=None,
notif_id = None
if event_type in (
_('Contact Signed In'), _('Contact Signed Out'),
_('New Message'), _('New Single Message'), _('New Private Message'),
_('New Message'), _('New Private Message'),
_('New Group Chat Message'),
_('Contact Changed Status'), _('File Transfer Request'),
_('File Transfer Error'), _('File Transfer Completed'),
......@@ -197,7 +195,6 @@ def popup(self, event_type, jid, account, type_='', icon_name=None,
elif event_type == _('Connection Failed'):
notif_id = self._make_id('connection-failed', account)
elif event_type in (_('New Message'),
_('New Single Message'),
_('New Private Message'),
_('New Group Chat Message')):
if app.desktop_env == 'gnome':
......@@ -268,7 +265,7 @@ def __init__(self, event_type, jid, account, msg_type='',
bg_color = app.config.get('notif_signin_color')
elif event_type == _('Contact Signed Out'):
bg_color = app.config.get('notif_signout_color')
elif event_type in (_('New Message'), _('New Single Message'),
elif event_type in (_('New Message'),
_('New Private Message'), _('New E-mail')):
bg_color = app.config.get('notif_message_color')
elif event_type == _('File Transfer Request'):
......
......@@ -1238,7 +1238,7 @@ def handle_event(self, account, fjid, type_):
ctrl = self.new_private_chat(gc_contact, account)
w = ctrl.parent_win
elif type_ in ('normal', 'file-request', 'file-request-error',
elif type_ in ('file-request', 'file-request-error',
'file-send-error', 'file-error', 'file-stopped', 'file-completed',
'file-hash-error', 'jingle-incoming'):
# Get the first single message event
......
......@@ -2654,14 +2654,8 @@ def _nec_decrypted_message_received(self, obj):
return True
if obj.properties.type.value not in ('normal', 'chat'):
return
if obj.properties.type.is_normal and obj.popup:
# it's single message to be autopopuped
SingleMessageWindow(obj.conn.name, obj.jid,
action='receive', from_whom=obj.jid, subject=obj.subject,
message=obj.msgtxt, resource=obj.resource, session=obj.session)
return
if obj.popup and obj.properties.type.is_chat and not obj.session.control:
if obj.popup and not obj.session.control:
contact = app.contacts.get_contact(obj.conn.name, obj.jid)
obj.session.control = app.interface.new_chat(contact,
obj.conn.name, session=obj.session)
......
......@@ -28,7 +28,6 @@
from gajim.common import ged
from gajim.common.helpers import AdditionalDataDict
from gajim.common.const import KindConstant
from gajim.gtk.single_message import SingleMessageWindow
from gajim.gtk.util import get_show_in_roster
from gajim.gtk.util import get_show_in_systray
......@@ -100,21 +99,12 @@ def _nec_decrypted_message_received(self, obj):
if self.control.resource:
self.control.change_resource(self.resource)
if obj.properties.type.is_chat:
if not obj.msgtxt:
return
log_type = KindConstant.CHAT_MSG_RECV
if obj.forwarded and obj.sent:
log_type = KindConstant.CHAT_MSG_SENT
else:
log_type = KindConstant.SINGLE_MSG_RECV
if obj.forwarded and obj.sent:
log_type = KindConstant.SINGLE_MSG_SENT
if not obj.msgtxt:
return
treat_as = app.config.get('treat_incoming_messages')
if treat_as:
obj.mtype = treat_as
log_type = KindConstant.CHAT_MSG_RECV
if obj.forwarded and obj.sent:
log_type = KindConstant.CHAT_MSG_SENT
if self.is_loggable() and obj.msgtxt:
if obj.xhtml and app.config.get('log_xhtml_messages'):
......@@ -211,11 +201,7 @@ def roster_message2(self, obj):
event_t = events.ChatEvent
event_type = 'message_received'
if obj.properties.type.is_normal:
event_t = events.NormalEvent
event_type = 'single_message_received'
if self.control and not obj.properties.type.is_normal:
if self.control:
# We have a ChatControl open
obj.show_in_roster = False
obj.show_in_systray = False
......@@ -236,10 +222,7 @@ def roster_message2(self, obj):
# Everything else
obj.show_in_roster = get_show_in_roster(event_type, self)
obj.show_in_systray = get_show_in_systray(event_type, contact.jid)
if obj.properties.type.is_normal and obj.popup:
do_event = False
else:
do_event = True
do_event = True
if do_event:
kind = obj.properties.type.value
event = event_t(obj.msgtxt, obj.subject, kind, obj.timestamp,
......@@ -313,14 +296,8 @@ def roster_message(self, jid, msg, tim, encrypted=False, msg_type='',
popup = helpers.allow_popup_window(self.conn.name)
if msg_type == 'normal' and popup: # it's single message to be autopopuped
SingleMessageWindow(self.conn.name, contact.jid,
action='receive', from_whom=jid, subject=subject, message=msg,
resource=resource, session=self)
return
# We print if window is opened and it's not a single message
if self.control and msg_type != 'normal':
if self.control:
typ = ''
if msg_type == 'error':
......@@ -339,10 +316,6 @@ def roster_message(self, jid, msg, tim, encrypted=False, msg_type='',
event_t = events.ChatEvent
event_type = 'message_received'
if msg_type == 'normal':
event_t = events.NormalEvent
event_type = 'single_message_received'
show_in_roster = get_show_in_roster(event_type, self)
show_in_systray = get_show_in_systray(event_type, contact.jid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment