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,
|
def handle_message_textview_mykey_press(self, widget, event_keyval,
|
||||||
event_keymod):
|
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):
|
def status_url_clicked(self, widget, url):
|
||||||
helpers.launch_browser_mailer('url', url)
|
helpers.launch_browser_mailer('url', url)
|
||||||
|
@ -167,12 +169,14 @@ class ChatControlBase(MessageControl):
|
||||||
self._on_banner_eventbox_button_press_event)
|
self._on_banner_eventbox_button_press_event)
|
||||||
self.handlers[id_] = widget
|
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:
|
if gajim.HAVE_PYSEXY:
|
||||||
import sexy
|
import sexy
|
||||||
self.banner_status_label = sexy.UrlLabel()
|
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:
|
else:
|
||||||
self.banner_status_label = gtk.Label()
|
self.banner_status_label = gtk.Label()
|
||||||
self.banner_status_label.set_selectable(True)
|
self.banner_status_label.set_selectable(True)
|
||||||
|
@ -314,7 +318,8 @@ class ChatControlBase(MessageControl):
|
||||||
dialogs.AspellDictError(lang)
|
dialogs.AspellDictError(lang)
|
||||||
|
|
||||||
def on_msg_textview_populate_popup(self, textview, menu):
|
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):
|
def _on_select_dictionary(widget, lang):
|
||||||
per_type = 'contacts'
|
per_type = 'contacts'
|
||||||
if self.type_id == message_control.TYPE_GC:
|
if self.type_id == message_control.TYPE_GC:
|
||||||
|
@ -664,7 +669,7 @@ class ChatControlBase(MessageControl):
|
||||||
# other_tags_for_text == ['marked'] --> highlighted gc message
|
# other_tags_for_text == ['marked'] --> highlighted gc message
|
||||||
gajim.last_message_time[self.account][full_jid] = time.time()
|
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
|
gc_message = False
|
||||||
if self.type_id == message_control.TYPE_GC:
|
if self.type_id == message_control.TYPE_GC:
|
||||||
gc_message = True
|
gc_message = True
|
||||||
|
@ -674,7 +679,7 @@ class ChatControlBase(MessageControl):
|
||||||
not self.parent_win.is_active() or not end)) or \
|
not self.parent_win.is_active() or not end)) or \
|
||||||
(gc_message and \
|
(gc_message and \
|
||||||
jid in gajim.interface.minimized_controls[self.account])) 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
|
# we want to have save this message in events list
|
||||||
# other_tags_for_text == ['marked'] --> highlighted gc message
|
# other_tags_for_text == ['marked'] --> highlighted gc message
|
||||||
if gc_message:
|
if gc_message:
|
||||||
|
@ -706,7 +711,7 @@ class ChatControlBase(MessageControl):
|
||||||
if (not self.parent_win.get_active_control() or \
|
if (not self.parent_win.get_active_control() or \
|
||||||
self != 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 \
|
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)
|
self.parent_win.redraw_tab(self)
|
||||||
if not self.parent_win.is_active():
|
if not self.parent_win.is_active():
|
||||||
self.parent_win.show_title(True, self) # Enabled Urgent hint
|
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,
|
def print_conversation(self, text, frm='', tim=None, encrypted=False,
|
||||||
subject=None, xhtml=None, simple=False, xep0184_id=None):
|
subject=None, xhtml=None, simple=False, xep0184_id=None):
|
||||||
# TODO: contact? ITYM frm.
|
|
||||||
'''Print a line in the conversation:
|
'''Print a line in the conversation:
|
||||||
if contact is set to status: it's a status message
|
if frm is set to status: it's a status message
|
||||||
if contact is set to another value: it's an outgoing message
|
if frm is set to error: it's an error message
|
||||||
if contact is set to print_queue: it is incomming from queue
|
if frm is set to info: it's a information message
|
||||||
if contact is not set: it's an incomming 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
|
contact = self.contact
|
||||||
|
|
||||||
if frm == 'status':
|
if frm == 'status':
|
||||||
|
@ -1915,6 +1921,9 @@ class ChatControl(ChatControlBase):
|
||||||
return
|
return
|
||||||
kind = 'status'
|
kind = 'status'
|
||||||
name = ''
|
name = ''
|
||||||
|
elif frm == 'error':
|
||||||
|
kind = 'error'
|
||||||
|
name = ''
|
||||||
elif frm == 'info':
|
elif frm == 'info':
|
||||||
kind = 'info'
|
kind = 'info'
|
||||||
name = ''
|
name = ''
|
||||||
|
|
|
@ -1154,7 +1154,7 @@ class ConversationTextview:
|
||||||
buffer_.insert_with_tags_by_name(end_iter, tim_format + '\n',
|
buffer_.insert_with_tags_by_name(end_iter, tim_format + '\n',
|
||||||
'time_sometimes')
|
'time_sometimes')
|
||||||
# kind = info, we print things as if it was a status: same color, ...
|
# kind = info, we print things as if it was a status: same color, ...
|
||||||
if kind == 'info':
|
if kind in ('error', 'info'):
|
||||||
kind = 'status'
|
kind = 'status'
|
||||||
other_text_tag = self.detect_other_text_tag(text, kind)
|
other_text_tag = self.detect_other_text_tag(text, kind)
|
||||||
text_tags = other_tags_for_text[:] # create a new list
|
text_tags = other_tags_for_text[:] # create a new list
|
||||||
|
|
|
@ -296,12 +296,17 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
self.conn.name, jid, user_nick)
|
self.conn.name, jid, user_nick)
|
||||||
|
|
||||||
if not self.control:
|
if not self.control:
|
||||||
# if no control exists and message comes from highest prio, the new
|
ctrl = gajim.interface.msg_win_mgr.get_control(fjid, self.conn.name)
|
||||||
# control shouldn't have a resource
|
if ctrl:
|
||||||
if highest_contact and contact.resource == highest_contact.resource \
|
self.control = ctrl
|
||||||
and not jid == gajim.get_jid_from_account(self.conn.name):
|
self.control.set_session(self)
|
||||||
fjid = jid
|
else:
|
||||||
resource_for_chat = None
|
# 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\
|
||||||
|
and not jid == gajim.get_jid_from_account(self.conn.name):
|
||||||
|
fjid = jid
|
||||||
|
resource_for_chat = None
|
||||||
|
|
||||||
# Do we have a queue?
|
# Do we have a queue?
|
||||||
no_queue = len(gajim.events.get_events(self.conn.name, fjid)) == 0
|
no_queue = len(gajim.events.get_events(self.conn.name, fjid)) == 0
|
||||||
|
@ -319,7 +324,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
typ = ''
|
typ = ''
|
||||||
|
|
||||||
if msg_type == 'error':
|
if msg_type == 'error':
|
||||||
typ = 'status'
|
typ = 'error'
|
||||||
|
|
||||||
self.control.print_conversation(msg, typ, tim=tim, encrypted=encrypted,
|
self.control.print_conversation(msg, typ, tim=tim, encrypted=encrypted,
|
||||||
subject=subject, xhtml=xhtml)
|
subject=subject, xhtml=xhtml)
|
||||||
|
|
Loading…
Reference in New Issue