don't show more than one error dialog for a given groupchat. Fixes #5753
This commit is contained in:
		
							parent
							
								
									469d496dcb
								
							
						
					
					
						commit
						493dbce89d
					
				
					 4 changed files with 51 additions and 24 deletions
				
			
		|  | @ -1784,33 +1784,39 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle): | ||||||
|                 elif (errcode == '503'): |                 elif (errcode == '503'): | ||||||
|                     if gc_control is None or gc_control.autorejoin is None: |                     if gc_control is None or gc_control.autorejoin is None: | ||||||
|                         # maximum user number reached |                         # maximum user number reached | ||||||
|                         self.dispatch('ERROR', (_('Unable to join group chat'), |                         self.dispatch('GC_ERROR', (gc_control, | ||||||
|                                 _('Maximum number of users for %s has been reached') % \ |                             _('Unable to join group chat'), | ||||||
|                                 room_jid)) |                             _('Maximum number of users for %s has been ' | ||||||
|  |                             'reached') % room_jid)) | ||||||
|                 elif (errcode == '401') or (errcon == 'not-authorized'): |                 elif (errcode == '401') or (errcon == 'not-authorized'): | ||||||
|                     # password required to join |                     # password required to join | ||||||
|                     self.dispatch('GC_PASSWORD_REQUIRED', (room_jid, nick)) |                     self.dispatch('GC_PASSWORD_REQUIRED', (room_jid, nick)) | ||||||
|                 elif (errcode == '403') or (errcon == 'forbidden'): |                 elif (errcode == '403') or (errcon == 'forbidden'): | ||||||
|                     # we are banned |                     # we are banned | ||||||
|                     self.dispatch('ERROR', (_('Unable to join group chat'), |                     self.dispatch('GC_ERROR', (gc_control, | ||||||
|                             _('You are banned from group chat %s.') % room_jid)) |                         _('Unable to join group chat'), | ||||||
|  |                         _('You are banned from group chat %s.') % room_jid)) | ||||||
|                 elif (errcode == '404') or (errcon in ('item-not-found', |                 elif (errcode == '404') or (errcon in ('item-not-found', | ||||||
|                 'remote-server-not-found')): |                 'remote-server-not-found')): | ||||||
|                     if gc_control is None or gc_control.autorejoin is None: |                     if gc_control is None or gc_control.autorejoin is None: | ||||||
|                         # group chat does not exist |                         # group chat does not exist | ||||||
|                         self.dispatch('ERROR', (_('Unable to join group chat'), |                         self.dispatch('GC_ERROR', (gc_control, | ||||||
|                                 _('Group chat %s does not exist.') % room_jid)) |                             _('Unable to join group chat'), | ||||||
|  |                             _('Group chat %s does not exist.') % room_jid)) | ||||||
|                 elif (errcode == '405') or (errcon == 'not-allowed'): |                 elif (errcode == '405') or (errcon == 'not-allowed'): | ||||||
|                     self.dispatch('ERROR', (_('Unable to join group chat'), |                     self.dispatch('GC_ERROR', (gc_control, | ||||||
|                             _('Group chat creation is restricted.'))) |                         _('Unable to join group chat'), | ||||||
|  |                         _('Group chat creation is restricted.'))) | ||||||
|                 elif (errcode == '406') or (errcon == 'not-acceptable'): |                 elif (errcode == '406') or (errcon == 'not-acceptable'): | ||||||
|                     self.dispatch('ERROR', (_('Unable to join group chat'), |                     self.dispatch('GC_ERROR', (gc_control, | ||||||
|                             _('Your registered nickname must be used in group chat %s.') \ |                         _('Unable to join group chat'), | ||||||
|                             % room_jid)) |                         _('Your registered nickname must be used in group chat ' | ||||||
|  |                         '%s.') % room_jid)) | ||||||
|                 elif (errcode == '407') or (errcon == 'registration-required'): |                 elif (errcode == '407') or (errcon == 'registration-required'): | ||||||
|                     self.dispatch('ERROR', (_('Unable to join group chat'), |                     self.dispatch('GC_ERROR', (gc_control, | ||||||
|                             _('You are not in the members list in groupchat %s.') % \ |                         _('Unable to join group chat'), | ||||||
|                             room_jid)) |                         _('You are not in the members list in groupchat %s.') %\ | ||||||
|  |                         room_jid)) | ||||||
|                 elif (errcode == '409') or (errcon == 'conflict'): |                 elif (errcode == '409') or (errcon == 'conflict'): | ||||||
|                     # nick conflict |                     # nick conflict | ||||||
|                     room_jid = gajim.get_room_from_fjid(who) |                     room_jid = gajim.get_room_from_fjid(who) | ||||||
|  |  | ||||||
|  | @ -1242,8 +1242,9 @@ class AboutDialog: | ||||||
| 
 | 
 | ||||||
| class Dialog(gtk.Dialog): | class Dialog(gtk.Dialog): | ||||||
|     def __init__(self, parent, title, buttons, default=None, |     def __init__(self, parent, title, buttons, default=None, | ||||||
|                              on_response_ok=None, on_response_cancel=None): |     on_response_ok=None, on_response_cancel=None): | ||||||
|         gtk.Dialog.__init__(self, title, parent, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) |         gtk.Dialog.__init__(self, title, parent, | ||||||
|  |             gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) | ||||||
| 
 | 
 | ||||||
|         self.user_response_ok = on_response_ok |         self.user_response_ok = on_response_ok | ||||||
|         self.user_response_cancel = on_response_cancel |         self.user_response_cancel = on_response_cancel | ||||||
|  | @ -1480,8 +1481,8 @@ class InformationDialog(HigDialog): | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     def __init__(self, pritext, sectext=''): |     def __init__(self, pritext, sectext=''): | ||||||
|         HigDialog.__init__(self, None, |         HigDialog.__init__(self, None, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, | ||||||
|                                            gtk.MESSAGE_INFO, gtk.BUTTONS_OK, pritext, sectext) |             pritext, sectext) | ||||||
|         self.set_modal(False) |         self.set_modal(False) | ||||||
|         self.set_transient_for(gajim.interface.roster.window) |         self.set_transient_for(gajim.interface.roster.window) | ||||||
|         self.popup() |         self.popup() | ||||||
|  | @ -1491,9 +1492,11 @@ class ErrorDialog(HigDialog): | ||||||
|     HIG compliant error dialog |     HIG compliant error dialog | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|     def __init__(self, pritext, sectext=''): |     def __init__(self, pritext, sectext='', on_response_ok=None, | ||||||
|         HigDialog.__init__( self, None, |     on_response_cancel=None): | ||||||
|                                                 gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, pritext, sectext) |         HigDialog.__init__( self, None, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, | ||||||
|  |             pritext, sectext, on_response_ok=on_response_ok, | ||||||
|  |             on_response_cancel=on_response_cancel) | ||||||
|         self.popup() |         self.popup() | ||||||
| 
 | 
 | ||||||
| class YesNoDialog(HigDialog): | class YesNoDialog(HigDialog): | ||||||
|  |  | ||||||
|  | @ -216,6 +216,9 @@ class GroupchatControl(ChatControlBase): | ||||||
|         #       state in got_connected()). |         #       state in got_connected()). | ||||||
|         self.autorejoin = None |         self.autorejoin = None | ||||||
| 
 | 
 | ||||||
|  |         # Keep error dialog instance to be sure to have only once at a time | ||||||
|  |         self.error_dialog = None | ||||||
|  | 
 | ||||||
|         self.actions_button = self.xml.get_object('muc_window_actions_button') |         self.actions_button = self.xml.get_object('muc_window_actions_button') | ||||||
|         id_ = self.actions_button.connect('clicked', |         id_ = self.actions_button.connect('clicked', | ||||||
|             self.on_actions_button_clicked) |             self.on_actions_button_clicked) | ||||||
|  | @ -1263,8 +1266,8 @@ class GroupchatControl(ChatControlBase): | ||||||
|                             '%(reason)s') % { 'nick': nick, 'who': actor, |                             '%(reason)s') % { 'nick': nick, 'who': actor, | ||||||
|                             'reason': reason } |                             'reason': reason } | ||||||
|                     self.print_conversation(s, 'info', tim=tim, graphics=False) |                     self.print_conversation(s, 'info', tim=tim, graphics=False) | ||||||
|                     if nick == self.nick: | #                    if nick == self.nick: | ||||||
|                         self.autorejoin = False | #                        self.autorejoin = False | ||||||
|                 elif '303' in statusCode: # Someone changed his or her nick |                 elif '303' in statusCode: # Someone changed his or her nick | ||||||
|                     if new_nick == self.new_nick or nick == self.nick: |                     if new_nick == self.new_nick or nick == self.nick: | ||||||
|                         # We changed our nick |                         # We changed our nick | ||||||
|  |  | ||||||
|  | @ -1151,6 +1151,20 @@ class Interface: | ||||||
|             notify.popup(event_type, jid, account, 'gc-invitation', path, |             notify.popup(event_type, jid, account, 'gc-invitation', path, | ||||||
|                     event_type, room_jid) |                     event_type, room_jid) | ||||||
| 
 | 
 | ||||||
|  |     def handle_event_gc_error(self, account, data): | ||||||
|  |         #('ERROR', account, (gc_control, title_text, section_text)) | ||||||
|  |         gc_control, pritext, sectext = data | ||||||
|  |         if gc_control: | ||||||
|  |             if gc_control.error_dialog: | ||||||
|  |                 gc_control.error_dialog.destroy() | ||||||
|  |             def on_close(dummy): | ||||||
|  |                 gc_control.error_dialog.destroy() | ||||||
|  |                 gc_control.error_dialog = None | ||||||
|  |             gc_control.error_dialog = dialogs.ErrorDialog(pritext, sectext, | ||||||
|  |                 on_response_ok=on_close, on_response_cancel=on_close) | ||||||
|  |         else: | ||||||
|  |             dialogs.ErrorDialog(pritext, sectext) | ||||||
|  | 
 | ||||||
|     def forget_gpg_passphrase(self, keyid): |     def forget_gpg_passphrase(self, keyid): | ||||||
|         if keyid in self.gpg_passphrase: |         if keyid in self.gpg_passphrase: | ||||||
|             del self.gpg_passphrase[keyid] |             del self.gpg_passphrase[keyid] | ||||||
|  | @ -2126,6 +2140,7 @@ class Interface: | ||||||
|             'GC_INVITATION': [self.handle_event_gc_invitation], |             'GC_INVITATION': [self.handle_event_gc_invitation], | ||||||
|             'GC_AFFILIATION': [self.handle_event_gc_affiliation], |             'GC_AFFILIATION': [self.handle_event_gc_affiliation], | ||||||
|             'GC_PASSWORD_REQUIRED': [self.handle_event_gc_password_required], |             'GC_PASSWORD_REQUIRED': [self.handle_event_gc_password_required], | ||||||
|  |             'GC_ERROR': [self.handle_event_gc_error], | ||||||
|             'BAD_PASSPHRASE': [self.handle_event_bad_passphrase], |             'BAD_PASSPHRASE': [self.handle_event_bad_passphrase], | ||||||
|             'ROSTER_INFO': [self.handle_event_roster_info], |             'ROSTER_INFO': [self.handle_event_roster_info], | ||||||
|             'BOOKMARKS': [self.handle_event_bookmarks], |             'BOOKMARKS': [self.handle_event_bookmarks], | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue