handle error messages correctly. Fixes #4783
This commit is contained in:
parent
6f951d20d0
commit
beb32a3d1c
|
@ -134,7 +134,9 @@ class ChatControlBase(MessageControl):
|
|||
|
||||
def handle_message_textview_mykey_press(self, widget, event_keyval,
|
||||
event_keymod):
|
||||
pass # Derived should implement this rather than connecting to the event itself.
|
||||
# Derived should implement this rather than connecting to the event
|
||||
# itself.
|
||||
pass
|
||||
|
||||
def status_url_clicked(self, widget, url):
|
||||
helpers.launch_browser_mailer('url', url)
|
||||
|
@ -167,12 +169,14 @@ class ChatControlBase(MessageControl):
|
|||
self._on_banner_eventbox_button_press_event)
|
||||
self.handlers[id_] = widget
|
||||
|
||||
self.urlfinder = re.compile(r"(www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'\"]+[^!,\.\s<>\)'\"\]]")
|
||||
self.urlfinder = re.compile(
|
||||
r"(www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'\"]+[^!,\.\s<>\)'\"\]]")
|
||||
|
||||
if gajim.HAVE_PYSEXY:
|
||||
import sexy
|
||||
self.banner_status_label = sexy.UrlLabel()
|
||||
self.banner_status_label.connect('url_activated', self.status_url_clicked)
|
||||
self.banner_status_label.connect('url_activated',
|
||||
self.status_url_clicked)
|
||||
else:
|
||||
self.banner_status_label = gtk.Label()
|
||||
self.banner_status_label.set_selectable(True)
|
||||
|
@ -314,7 +318,8 @@ class ChatControlBase(MessageControl):
|
|||
dialogs.AspellDictError(lang)
|
||||
|
||||
def on_msg_textview_populate_popup(self, textview, menu):
|
||||
'''we override the default context menu and we prepend an option to switch languages'''
|
||||
'''we override the default context menu and we prepend an option to switch
|
||||
languages'''
|
||||
def _on_select_dictionary(widget, lang):
|
||||
per_type = 'contacts'
|
||||
if self.type_id == message_control.TYPE_GC:
|
||||
|
@ -664,7 +669,7 @@ class ChatControlBase(MessageControl):
|
|||
# other_tags_for_text == ['marked'] --> highlighted gc message
|
||||
gajim.last_message_time[self.account][full_jid] = time.time()
|
||||
|
||||
if kind in ('incoming', 'incoming_queue'):
|
||||
if kind in ('incoming', 'incoming_queue', 'error'):
|
||||
gc_message = False
|
||||
if self.type_id == message_control.TYPE_GC:
|
||||
gc_message = True
|
||||
|
@ -674,7 +679,7 @@ class ChatControlBase(MessageControl):
|
|||
not self.parent_win.is_active() or not end)) or \
|
||||
(gc_message and \
|
||||
jid in gajim.interface.minimized_controls[self.account])) and \
|
||||
kind in ('incoming', 'incoming_queue'):
|
||||
kind in ('incoming', 'incoming_queue', 'error'):
|
||||
# we want to have save this message in events list
|
||||
# other_tags_for_text == ['marked'] --> highlighted gc message
|
||||
if gc_message:
|
||||
|
@ -706,7 +711,7 @@ class ChatControlBase(MessageControl):
|
|||
if (not self.parent_win.get_active_control() or \
|
||||
self != self.parent_win.get_active_control() or \
|
||||
not self.parent_win.is_active() or not end) and \
|
||||
kind in ('incoming', 'incoming_queue'):
|
||||
kind in ('incoming', 'incoming_queue', 'error'):
|
||||
self.parent_win.redraw_tab(self)
|
||||
if not self.parent_win.is_active():
|
||||
self.parent_win.show_title(True, self) # Enabled Urgent hint
|
||||
|
@ -1902,12 +1907,13 @@ class ChatControl(ChatControlBase):
|
|||
|
||||
def print_conversation(self, text, frm='', tim=None, encrypted=False,
|
||||
subject=None, xhtml=None, simple=False, xep0184_id=None):
|
||||
# TODO: contact? ITYM frm.
|
||||
'''Print a line in the conversation:
|
||||
if contact is set to status: it's a status message
|
||||
if contact is set to another value: it's an outgoing message
|
||||
if contact is set to print_queue: it is incomming from queue
|
||||
if contact is not set: it's an incomming message'''
|
||||
if frm is set to status: it's a status message
|
||||
if frm is set to error: it's an error message
|
||||
if frm is set to info: it's a information message
|
||||
if frm is set to print_queue: it is incomming from queue
|
||||
if frm is set to another value: it's an outgoing message
|
||||
if frm is not set: it's an incomming message'''
|
||||
contact = self.contact
|
||||
|
||||
if frm == 'status':
|
||||
|
@ -1915,6 +1921,9 @@ class ChatControl(ChatControlBase):
|
|||
return
|
||||
kind = 'status'
|
||||
name = ''
|
||||
elif frm == 'error':
|
||||
kind = 'error'
|
||||
name = ''
|
||||
elif frm == 'info':
|
||||
kind = 'info'
|
||||
name = ''
|
||||
|
|
|
@ -1154,7 +1154,7 @@ class ConversationTextview:
|
|||
buffer_.insert_with_tags_by_name(end_iter, tim_format + '\n',
|
||||
'time_sometimes')
|
||||
# kind = info, we print things as if it was a status: same color, ...
|
||||
if kind == 'info':
|
||||
if kind in ('error', 'info'):
|
||||
kind = 'status'
|
||||
other_text_tag = self.detect_other_text_tag(text, kind)
|
||||
text_tags = other_tags_for_text[:] # create a new list
|
||||
|
|
|
@ -296,9 +296,14 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
self.conn.name, jid, user_nick)
|
||||
|
||||
if not self.control:
|
||||
ctrl = gajim.interface.msg_win_mgr.get_control(fjid, self.conn.name)
|
||||
if ctrl:
|
||||
self.control = ctrl
|
||||
self.control.set_session(self)
|
||||
else:
|
||||
# if no control exists and message comes from highest prio, the new
|
||||
# control shouldn't have a resource
|
||||
if highest_contact and contact.resource == highest_contact.resource \
|
||||
if highest_contact and contact.resource == highest_contact.resource\
|
||||
and not jid == gajim.get_jid_from_account(self.conn.name):
|
||||
fjid = jid
|
||||
resource_for_chat = None
|
||||
|
@ -319,7 +324,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
typ = ''
|
||||
|
||||
if msg_type == 'error':
|
||||
typ = 'status'
|
||||
typ = 'error'
|
||||
|
||||
self.control.print_conversation(msg, typ, tim=tim, encrypted=encrypted,
|
||||
subject=subject, xhtml=xhtml)
|
||||
|
|
Loading…
Reference in New Issue