fix #2545, pop up error message when publishing fails
This commit is contained in:
parent
ccf2b261c7
commit
41594ac4e8
|
@ -517,8 +517,7 @@ class ClientZeroconf:
|
|||
def zeroconf_init(self, show, msg):
|
||||
self.zeroconf = zeroconf.Zeroconf(self.caller._on_new_service,
|
||||
self.caller._on_remove_service, self.caller._on_name_conflictCB,
|
||||
self.caller._on_disconnected, self.caller.username, self.caller.host,
|
||||
self.port)
|
||||
self.caller._on_disconnected, self.caller._on_error, self.caller.username, self.caller.host, self.port)
|
||||
self.zeroconf.txt['msg'] = msg
|
||||
self.zeroconf.txt['status'] = show
|
||||
self.zeroconf.txt['1st'] = self.caller.first
|
||||
|
|
|
@ -90,11 +90,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
|||
self.muc_jid = {} # jid of muc server for each transport type
|
||||
self.vcard_supported = False
|
||||
|
||||
def _on_name_conflictCB(self, alt_name):
|
||||
self.disconnect()
|
||||
self.dispatch('STATUS', 'offline')
|
||||
self.dispatch('ZC_NAME_CONFLICT', alt_name)
|
||||
|
||||
def get_config_values_or_default(self):
|
||||
''' get name, host, port from config, or
|
||||
create zeroconf account with default values'''
|
||||
|
@ -206,6 +201,14 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
|||
self.status = 'offline'
|
||||
self.disconnect()
|
||||
|
||||
def _on_name_conflictCB(self, alt_name):
|
||||
self.disconnect()
|
||||
self.dispatch('STATUS', 'offline')
|
||||
self.dispatch('ZC_NAME_CONFLICT', alt_name)
|
||||
|
||||
def _on_error(self, message):
|
||||
self.dispatch('ERROR', (_('Avahi error'), _("%s\nLink-local messaging might not work properly.") % message))
|
||||
|
||||
def connect(self, show = 'online', msg = ''):
|
||||
self.get_config_values_or_default()
|
||||
if not self.connection:
|
||||
|
|
|
@ -34,7 +34,7 @@ C_ADDRESS, C_PORT, C_BARE_NAME, C_TXT = range(9)
|
|||
|
||||
class Zeroconf:
|
||||
def __init__(self, new_serviceCB, remove_serviceCB, name_conflictCB,
|
||||
disconnected_CB, name, host, port):
|
||||
disconnected_CB, error_CB, name, host, port):
|
||||
self.server = None
|
||||
self.domain = None # specific domain to browse
|
||||
self.stype = '_presence._tcp'
|
||||
|
@ -49,6 +49,7 @@ class Zeroconf:
|
|||
self.remove_serviceCB = remove_serviceCB
|
||||
self.name_conflictCB = name_conflictCB
|
||||
self.disconnected_CB = disconnected_CB
|
||||
self.error_CB = error_CB
|
||||
|
||||
self.service_browser = None
|
||||
self.domain_browser = None
|
||||
|
@ -166,9 +167,12 @@ class Zeroconf:
|
|||
|
||||
def service_add_fail_callback(self, err):
|
||||
gajim.log.debug('Error while adding service. %s' % str(err))
|
||||
alternative_name = self.server.GetAlternativeServiceName(self.username)
|
||||
if str(err) == 'Local name collision':
|
||||
alternative_name = self.server.GetAlternativeServiceName(self.username)
|
||||
self.name_conflictCB(alternative_name)
|
||||
else:
|
||||
self.error_CB(_('Error while adding service. %s') % str(err))
|
||||
self.disconnect()
|
||||
self.name_conflictCB(alternative_name)
|
||||
|
||||
def server_state_changed_callback(self, state, error):
|
||||
print 'server.state %s' % state
|
||||
|
|
Loading…
Reference in New Issue